I am trying to obtain a list of products inside a category searching by the category ID and the website ID.
Right now I have all the products of the category correctly, but the website filter isn't working, I selected a product to be in for example website Peru, but not Venezuela, but it doesn't respect that and it is always returning the product.
First I am obtaining the website id based on its code, which gives me the right value. I am using setStoreId then.
This is the part of code:
$currentCountry = Mage::getModel('core/store')->loadConfig('ve')->getId(); $productData = Mage::getModel('catalog/category')->load($category->getId()) ->getProductCollection() ->setStoreId($currentCountry) ->addAttributeToSelect('*') ->addAttributeToFilter('status', 1) ->addAttributeToFilter('visibility', 4)
In the product page, in the Websites submenu, I have checked Peru, but not Venezuela.
Solved! Go to Solution.
You probably want to add a store filter to that collection before using it, like so:
That should filter the collection based on the selected website.