So, after i add an item to cart it will open a drawer with the information of that product added to cart and below that all his upsell products. In my CartController.php the code is like that:

$product = $this->_initProduct();
productId = $this->__(Mage::helper('core')->htmlEscape($product->getId()));
                    Mage::register('product', Mage::getModel('catalog/product')->load($productId));
                    $block = Mage::app()->getLayout()->createBlock('catalog/product_list_upsell')->setTemplate('catalog/product/list/upsell.phtml');
                    //set the product
                    $message2 .= $block->toHTml();

These upsell products are displayed like card, but i want them to be displayed like a table and i want to display only the image, price, name and i want to add 2 buttons: "Details" that will sent you to product page and "Add to cart" that will add that product also in cart. How can i do this? I tried with $product->getUpSellProductCollection() and foreach but nothing happen.

1 Answer 1


If somebody need this, this is the answer:

$_product = Mage::getModel('catalog/product')->load($productId);
$upsell = $_product->getUpsellProductCollection();
foreach ($upsell as $product) {
       $productId = $product->getId();
       $model_upsell = Mage::getModel('catalog/product');
       $_product_upsell = $model_upsell->load($productId);
       $upsell_name = $_product_upsell->getName();
       $message2.='<img src="'.Mage::getModel('catalog/product_media_config')
                   ->getMediaUrl($_product_upsell>getSmallImage()).'"width="200px">' . "<br>";

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.