Magento Related/upsell Product and products/category calls

Source: Internet
Author: User

Catalog/product Call

$product _model = Mage::getmodel (' catalog/product '); $product = $product _model->load ($product _id);  

  

Catalog/product_collection Call

$extra _links = Mage::getresourcemodel (' catalog/product_collection ')->addidfilter ($ Product_ids)->setstoreid (Mage::app ()->getstore (),getId ())->addminimalprice ()  ///getchildhtml will be  usedas low as--Addfinalprice (),addtaxpercents () ->addattributetoselect (Mage::getsingleton (' Catalog/config '),getproductattributes ())- >addurlrewrite ();  // URL rewrite for multiple products

Catalog/category Call (remove all products from a category)

$category _model= Mage::getmodel (' catalog/category ');$category _model->load ($category _id);//$category_name $category _model->getname () can be obtained through $category_id;$product _collection=$category _model-getproductcollection ();foreach($product _collection  as $_product) {$product _id=$_product-getId (); $product _name=$_product-getName ();} 

catalog/Category_collection Call$currentCatIds=$_product-getcategoryids ();$categoryCollection=mage::getresourcemodel (' catalog/category_collection ')//with Mage::getmodel (' Catalog/category ')->getcollection ();->addattributetoselect (' name ')                 ->addattributetoselect (' url ')                 ->addfieldtofilter (' Level ',Array(' Gteq ' =>1)); ->addattributetofilter (' entity_id ',$currentCatIds)                 -Addisactivefilter ();//Take out all the categories//First of a product:$product=$this-getproduct ();$product _id=$product-getId ();$product _ids=$product-getcategoryids ();//The second type:$category _model= Mage::getmodel (' catalog/category ');$category _model->load ($category _id);$product _collection=$category _model-getproductcollection ();$product _ids=Array();foreach($product _collection  as $product) {$product _ids[] =$product-getId ();} 
catalog/Category_collection Call$currentCatIds=$_product-getcategoryids ();$categoryCollection=mage::getresourcemodel (' catalog/category_collection ')//with Mage::getmodel (' Catalog/category ')->getcollection ();->addattributetoselect (' name ')                 ->addattributetoselect (' url ')                 ->addfieldtofilter (' Level ',Array(' Gteq ' =>1)); ->addattributetofilter (' entity_id ',$currentCatIds)                 -Addisactivefilter ();//Take out all the categories//First of a product:$product=$this-getproduct ();$product _id=$product-getId ();$product _ids=$product-getcategoryids ();//The second type:$category _model= Mage::getmodel (' catalog/category ');$category _model->load ($category _id);$product _collection=$category _model-getproductcollection ();$product _ids=Array();foreach($product _collection  as $product) {$product _ids[] =$product-getId ();} 

Magento related products related and bottom recommended products upsell cannot repeat

This issue should take into account the related module and the Upsell module who first loaded the problem results prove that the content of the Upsell module first loaded (this loading by the way can be adjusted temporarily no research)

So first record Mage::register ("Upsell_used_product_ids", $all _product_ids); The related product module calls Mage::registry (' Upsell_used_product_ids ') to filter the products that already exist in the Upsell

Magento Related/upsell Product and products/category calls

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.