• Get Realted, Upsell, Cross sell Product collection in magento


     
     
    Get Related Product Collection



    $related_product_collection = $_product->getRelatedProductCollection();
    $related_product_collection->AddStoreFilter();
    foreach($related_product_collection as $pdt)
    {
        $pdt_id=$pdt->getId();
        $model_rel = Mage::getModel('catalog/product'); //getting product model
        $_product_rel = $model_rel->load($pdt_id); //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(156,107);   //Image resize code
    ?>



    Get Upsell Product Collection



    <?php
    $upsell_product_collection = $_product->getUpSellProductCollection();
    $upsell_product_collection->AddStoreFilter();
    foreach($upsell_product_collection as $pdt)
    {
        $pdt_id=$pdt->getId();
        $model_upsell = Mage::getModel('catalog/product');
        $_product_upsell = $model_upsell->load($pdt_id);
        $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(100,100);
    ?>



    Get Cross Sell Product Collection



    <?php
    $crossselll_product_collection = $_product->getCrossSellProducts(); $crossselll_product_collection>AddStoreFilter();
    foreach($crossselll_product_collection as $pdt)
    {
        $pdt_id=$pdt->getId();
        $model_crosssell = Mage::getModel('catalog/product');
        $_product_crosssell = $model_crosssell>load($pdt_id);
        $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(100,100);

    ?>

  • 相关阅读:
    【YbtOJ#20068】连通子图
    【YbtOJ#20067】糖果分配
    【GMOJ6801】模拟patrick
    【GMOJ6800】模拟spongebob
    【洛谷P4449】于神之怒加强版
    【洛谷P3601】签到题
    【洛谷P2408】不同子串个数
    【洛谷P3809】【模板】后缀排序
    【JZOJ1753】锻炼身体
    【GMOJ1164】求和
  • 原文地址:https://www.cnblogs.com/dongtong/p/6182562.html
Copyright © 2020-2023  润新知