简体   繁体   中英

Magento filter simple and configurable products together

Is there any way to filter simple and configurable products together on some attribute. And then show the products list. The configurable product would just be shown as any other simple product after the filter if it satisfies the filtering condition. I have tried some tricks but after filtering, the configurable products do not show up as they by themselves do not satisfy the filter though their child products satisfy the filter.

I know a way to separately take the configurable products and then apply the filter. But that's not wat i am looking for.

Any help is greatfully appreciated...

SIMPLE PRODUCT

$collectionSimple = Mage::getResourceModel('catalog/product_collection')
            ->addAttributeToFilter('type_id', array('eq' => 'simple'));

CONFIGURABLE PRODUCT

$collectionConfigurable = Mage::getResourceModel('catalog/product_collection')
            ->addAttributeToFilter('type_id', array('eq' => 'configurable'));

try this

I believe that you're looking for a collection that includes both simple and configurable products. Use this:

$collection = Mage::getModel('catalog/product')->getCollection()
  ->addAttributeToFilter('type_id', array('in' => array('simple','configurable')));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM