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

Modern Toys, Magical Moments: Why the Best Toy Shop in Noida Is More Than Just a Store

When it comes to children, there’s one universal truth: the right toy can spark imagination, build skills, and make memories…

6 months ago

Rediscovering Joy: A New Era of Creativity & Comfort in Toy Stores

In today’s digital age, where screens and gadgets dominate our children’s lives, there’s something heartwarming about a well-loved plush toy…

6 months ago

Unboxing Imagination: Discovering the Joy of Play at a Toy Store in Noida

In a world dominated by screens and fast-paced routines, it’s easy to forget the simple magic of a toy in…

6 months ago

Imagination Unboxed: Discover Joy at the Toy Shop in Delhi

In the heart of Delhi’s vibrant streets lies a world where imagination meets innovation — the magical universe of toys.…

6 months ago

Play with Purpose: Discovering the Ultimate Toy Store in Noida

When was the last time a toy truly amazed you—not just as a product, but as a thoughtful tool for…

6 months ago

From Tears to Toys: Exploring Modern Childhood through Delhi’s Favorite Toy Shop

In the digital age, the way we experience childhood has changed, but the essence remains the same—imagination, exploration, and joy.…

6 months ago