Skip to main content
2 of 6
format the code
Manashvi Birla
  • 8.9k
  • 9
  • 28
  • 53

Cross-sell product is not showing in the product detail page

In product detail page the following code is written to display the cross-sell product which are set from the admin side..
<?php echo $this->getChildHtml('crosssell'); ?>
But it is not showing anything although there are cross sell products present in the admin side and the cross-sell products are instock.

I looked into its respective block i.e.

app/core/code/Mage/Catalog/Block/Product/List/Crosssell.php

and the function where the product collection is formed is as follows..

protected function _prepareData()
{
    $product = Mage::registry('product');
    /* @var $product Mage_Catalog_Model_Product */

    $this->_itemCollection = $product->getCrossSellProductCollection()
        ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
        ->setPositionOrder()
        ->addStoreFilter();


    Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);

    $this->_itemCollection->load();

    foreach ($this->_itemCollection as $product) {
        $product->setDoNotUseCategoryId(true);
    }

    return $this;
}  

I got nothing related to cross sell product while doing var_dump($product). So how to get the cross sell product in the product collection.

Thanks.

Kishore Patra
  • 456
  • 10
  • 27