0

I have added a product in both of my stores, but it has been set as featured in only specific store. And now when I try to get the featured products of another store, the featured products of other store also get listed because they belong to that store. Below is my code, any help ?

$_productCollection = Mage::getModel('catalog/category')
                ->load(4)
                ->getProductCollection()
                ->addWebsiteFilter(WEB_ID)
                ->addAttributeToSelect('*')
                ->addAttributeToFilter('status', 1)
                ->addAttributeToFilter('featured', 1)

                ->clear()
                ->setPageSize(3)
                ->load();
0

Try this

<?php
$category = Mage::getModel('catalog/category')->load(4);

$_productCollection = $category->getProductCollection();

$_productCollection->addAttributeToSelect('*')
                ->addStoreFilter()
                ->addAttributeToFilter('status', 1)
                ->addAttributeToFilter('featured', 1)
                ->setPageSize(3)
                ->load();
?>
| improve this answer | |
1

Try this code

$_productCollection = Mage::getModel('catalog/category')
                ->load(4)
                ->getProductCollection()
                ->setStoreId($correct_store_id_for_website) // set store id here
                ->addAttributeToSelect('*')
                ->addAttributeToFilter('status', 1)
                ->addAttributeToFilter('featured', 1)

                ->clear()
                ->setPageSize(3)
                ->load();

Hope it helps you

| improve this answer | |
  • could you please explain a little, what has been exactly implemented – Deepanshu Goyal Jan 12 '16 at 12:21
  • have you assigned separate categories for each website? Right? Then you need to set that category option is_anchor to Yes – Rohit Kundale Jan 12 '16 at 12:24
  • @Deepanshu i have updated my answer give it a try – Rohit Kundale Jan 12 '16 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.