I want to only select products that have the website id of 1 and only 1, I don't want products that has websites ids of 1,2,3,... .
I want to select only products that are assigned to only website id 1, if I do the
$websiteIds=1
$productCollection = Mage::getResourceModel('catalog/product_collection');
$productCollection->addWebsiteFilter($websiteIds);
it does not show me what I want, it has products with website id 1 and other websites as well.
I think the solution is to use something like
addfieldtoFilter('website_ids',array('eq'=>(1)))
addfieldtoFilter('website_ids',array('neq'=>(2,3,4)))
however we have no such thing as website_ids, if I run this:
$productCollection = Mage::getResourceModel('catalog/product_collection');
$productCollection->addWebsiteFilter($websiteIds);
foreach($productCollection as $product)
{
echo $product->getWebsiteIds();
echo $product->getData("website_ids")
}
we don't have "website_ids" as an attribute that I can go and do it, so the echo $product->getData("website_ids")
is wrong and null, I was wondering how I can achieve this. I know that I can select all products and then get count($websiteids) and if the count was 1 and also website_id was equal to 1 I can tag the product as my selected product which I am looking, but I think it should have a better solution.
P.S, for example:
Product A has following websites 1,2,3
Product B has following websites 1,2,5
Product C has following websites 1
the program should only return C, however with the solution that I have I will have A,B,C which is not my goal.