3

Magento does not show up configurable base product in the best sellers. Code is:

// Filter only products with visibility catalog,search & catalog
$_visibility = array(
    Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG,
    Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH
);
$_storeId = Mage::app()->getStore()->getId();
$_collection = Mage::getResourceModel('reports/product_collection')
    ->addOrderedQty('', '', true, false, false)
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('visibility', $_visibility)
    ->addStoreFilter($_storeId)
    ->setOrder('ordered_qty', 'desc');
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($_collection);
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($_collection);

How to show configurable products? Also which tables this collection would query?

1
  • Did you solve this?
    – snh_nl
    Mar 10, 2016 at 20:19

1 Answer 1

0

You may try the following code to display the configurable products under the bestseller section.

// First make a copy, otherwise the rest of the page might be affected!
$collection = clone $this->getLoadedProductCollection();
// Unset the current products and filter before loading the next.
$collection->clear()->addAttributeToFilter('type_id', 'configurable')
                   ->load();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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