简体   繁体   中英

Magento: get thumbnail for crossel product

I am trying to display image thumbnails for the Crossell Products retrieved using:

$_crossSellProducts = $_product->getCrossSellProducts();

After clearing the /media/catalog/product/cache folder and the Magento cache, this still retrieves the image placeholder:

$this->helper('catalog/image')->init($_crossel_product, 'small_image')->resize(60);

The product images are displayed on the product-detail page.

How could this be solved?

Thank you very much in advance.

For get thumbnail type used below code $this->helper('catalog/image')->init($_crossel_product, 'thumbnail ')->resize(60);

Also.... I thought ,small image is not available for this products.

Indeed, as Amit Bera suggested, the thumbnails seem not to be available for the crossel products retrieved this way.

Got it working by loading the actual product object:

$_crossel_prod_obj = Mage::getModel('catalog/product')->load($_crossel_product->getId());
$this->helper('catalog/image')->init($_crossel_prod_obj, 'small_image')->resize(60);

Hope it helps.

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