If you want to show the base image in upsell products, instead the small image Please Follow the instructions and create a small extension with the following files.
1. create a file as follow:
app/code/local/Sushant/Upsell/Block/Product/List/Upsell.php
<?php
class Sushant_Upsell_Block_Product_List_Upsell extends Mage_Catalog_Block_Product_List_Upsell
{
protected function _prepareData()
{
$product = Mage::registry('product');
/* @var $product Mage_Catalog_Model_Product */
$this->_itemCollection = $product->getUpSellProductCollection()
->setPositionOrder()
->addStoreFilter()
;
if (Mage::helper('catalog')->isModuleEnabled('Mage_Checkout')) {
Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
Mage::getSingleton('checkout/session')->getQuoteId()
);
$this->_addProductAttributesAndPrices($this->_itemCollection);
}
// Mage::getSingleton('catalog/product_status')->addSaleableFilterToCollection($this->_itemCollection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
if ($this->getItemLimit('upsell') > 0) {
$this->_itemCollection->setPageSize($this->getItemLimit('upsell'));
}
$this->_itemCollection->addAttributeToSelect('image');//get base iamge
$this->_itemCollection->load();
/**
* Updating collection with desired items
*/
Mage::dispatchEvent('catalog_product_upsell', array(
'product' => $product,
'collection' => $this->_itemCollection,
'limit' => $this->getItemLimit()
));
foreach ($this->_itemCollection as $product) {
$product->setDoNotUseCategoryId(true);
}
return $this;
}
}
2.app/code/local/Sushant/Upsell/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Sushant_Upsell> <version>0.0.1</version> </Sushant_Upsell> </modules> <global> <blocks> <catalog> <rewrite> <product_list_upsell>Sushant_Upsell_Block_Product_List_Upsell</product_list_upsell> </rewrite> </catalog> </blocks> </global> </config>
3.Active your module
app/etc/modules/Sushant_Upsell.xml
<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Sushant_Upsell> <active>true</active> <codePool>local</codePool> </Sushant_Upsell> </modules> </config>
4.Finally Open upsell.phtml
app/design/frontend/Your package/Your theme/template/catalog/product/list
And find
<img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize(280) ?>" alt="<?php echo $this->escapeHtml($_link->getName()) ?>" />
And replace this line
<img src="<?php echo $this->helper('catalog/image')->init($_link, 'image')->resize(280) ?>" alt="<?php echo $this->escapeHtml($_link->getName()) ?>" />
0 Comments