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 ?>
App usage is growing steadily without showing any signs of slowing down. Hence, it is no surprise that mobile applications…
As the world has grown more digital, businesses have adapted themselves. An effectual adaptation includes online advertising. Offline advertising styles…
Step into a world where apps dance to the user's tune. Picture Instagram, a photo-sharing sensation that swept the globe.…
COVID-19 has led to a digitalization of lifestyle. As patients are taking their mental and physical health more seriously, healthcare…
Introduction WordPress, an immensely popular content management system (CMS), powers over 40% of the internet. What makes WordPress even more…
For moving companies trying to capture their market share amidst stiff competition, a tip or two about what they can…