Categories: Magento

Get Related, Upsell, Cross sell Product collection in Magento.?

Get Realted, Upsell, Cross sell Product collection in magento

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.

Get Related Product Collection

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
?>

Get Upsell Product Collection

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
?>

Get Cross Sell Product Collection

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
?>

Rohan pathak

Recent Posts

What Is a Progressive Web App? Why Would You Need One?

App usage is growing steadily without showing any signs of slowing down. Hence, it is no surprise that mobile applications…

11 months ago

7 Most Popular Paid Online Advertising Strategy

As the world has grown more digital, businesses have adapted themselves. An effectual adaptation includes online advertising. Offline advertising styles…

12 months ago

The Importance of User-Centered Design in Mobile App Development

Step into a world where apps dance to the user's tune. Picture Instagram, a photo-sharing sensation that swept the globe.…

1 year ago

Healthcare Mobile App Development: A Complete Guide for Founders

COVID-19 has led to a digitalization of lifestyle. As patients are taking their mental and physical health more seriously, healthcare…

1 year ago

Exploring Diverse WordPress Theme Niches: A Comprehensive Guide

Introduction WordPress, an immensely popular content management system (CMS), powers over 40% of the internet. What makes WordPress even more…

1 year ago

8 Awesome Blog Content Ideas for Movers to Skyrocket the SEO

For moving companies trying to capture their market share amidst stiff competition, a tip or two about what they can…

1 year ago