In this post we will guide you on how to add related, upsell and cross sell product collection in Magento. Before starting, first lets explain about what are Related, Upsell and Cross-sell Products respectively. These are the up-sale techniques that websites offer to increase their revenues from getting more products in the eyes of the user.
Related Products: It displays on the product page and they are related to the product that customer is viewing with respect to category or type itself.
Upsell Products: It displays on the product page and they are an upgrade to the products the customer may bought, and are generally priced higher with their regular prices.
Cross-sell Products: It mostly display on the shopping cart page and they are the products which customers usually buy along with the products that are in the cart itself.
Here is the syntax to add related product collection to your viewers page
$relatedProduct = $product->getRelatedProductCollection(); $relatedProduct->AddStoreFilter(); foreach($relatedProduct as $product) { $productid=$product->getId(); $model_rel = Mage::getModel('catalog/product'); //getting product model $product_rel = $model_rel->load($productid); //getting product object for particular product id $rel_name= $_product_rel->getName(); $rel_price= number_format($product_rel->getPrice(),2); $rel_img_url = $this->helper('catalog/image')-> init($_product_rel, 'image')->keepFrame(false)->resize(100,100); //Image resize code ?>
With this code you will be able to add upsell product collection to the website programmatically.
<?php $upsellproduct_collection = $_product->getUpSellProductCollection(); $upsellproduct_collection->AddStoreFilter(); foreach($upsellproduct_collection as $prduct) { $productid=$prduct->getId(); $model_upsell = Mage::getModel('catalog/product'); $product_upsell = $model_upsell->load($productid); $upsell_name= $product_upsell->getName(); $upsell_price= number_format($product_upsell->getPrice(),2); $upsell_img_url = $this->helper('catalog/image') ->init($_product_upsell, 'image') ->keepFrame(false)->resize(150,100);//Image resize code ?>
This code allow to add Cross sell product collection to the whole website set up programmatically.
<?php $crossselllproduct_collection = $_product->getCrossSellProducts(); $crossselllproduct_collection>AddStoreFilter(); foreach($crossselllproduct_collection as $product) { $productid=$product->getId(); $model_crosssell = Mage::getModel('catalog/product'); $product_crosssell = $model_crosssell>load($productid); $crosssell_name= $product_crosssell->getName(); $crosssell_price= number_format($product_crosssell->getPrice(),2); $crosssell_img_url = $this->helper('catalog/image') ->init($_product_crosssell, 'image') ->keepFrame(false)->resize(150,150);//Image resize code ?>
When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…
In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…
In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…
In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…
When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…
In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…