标签:
catalog/product调用
$product_model = Mage::getModel(‘catalog/product‘); $product = $product_model->load($product_id); //可通过product_id 获取 product_name$product->getName(); $product_url = $product->getUrlModel()->getUrl($product, array(‘_ignore_category‘=>true)); //单个产品的url rewrite $product->setProductUrl($product_url);
catalog/product_collection调用
$extra_links = Mage::getResourceModel(‘catalog/product_collection‘) ->addIdFilter($product_ids) ->setStoreId(Mage::app()->getStore()->getId()) ->addMinimalPrice() //getChildHtml会用到 as low as ->addFinalPrice() ->addTaxPercents() ->addAttributeToSelect(Mage::getSingleton(‘catalog/config‘)->getProductAttributes()) ->addUrlRewrite(); //多个产品的url rewrite
catalog/category调用(取出一个分类中的所有产品)
$category_model = Mage::getModel(‘catalog/category‘); $category_model->load($category_id); //可通过$category_id获取$category_name $category_model->getName(); $product_collection = $category_model->getProductCollection(); foreach($product_collection as $_product){ $product_id = $_product->getId(); $product_name = $_product->getName(); }
catalog/category_collection调用 $currentCatIds = $_product->getCategoryIds(); $categoryCollection =Mage::getResourceModel(‘catalog/category_collection‘) //同Mage::getModel(‘catalog/category‘)->getCollection(); ->addAttributeToSelect(‘name‘) ->addAttributeToSelect(‘url‘) ->addFieldToFilter(‘level‘, array(‘gteq‘=>1)); ->addAttributeToFilter(‘entity_id‘, $currentCatIds) ->addIsActiveFilter(); //取出一个产品所属的所有分类 //第一种: $product = $this->getProduct(); $product_id = $product->getId(); $product_ids = $product->getCategoryIds(); //第二种: $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调用 $currentCatIds = $_product->getCategoryIds(); $categoryCollection =Mage::getResourceModel(‘catalog/category_collection‘) //同Mage::getModel(‘catalog/category‘)->getCollection(); ->addAttributeToSelect(‘name‘) ->addAttributeToSelect(‘url‘) ->addFieldToFilter(‘level‘, array(‘gteq‘=>1)); ->addAttributeToFilter(‘entity_id‘, $currentCatIds) ->addIsActiveFilter(); //取出一个产品所属的所有分类 //第一种: $product = $this->getProduct(); $product_id = $product->getId(); $product_ids = $product->getCategoryIds(); //第二种: $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 和 底部推荐产品 upsell 不能重复
这个问题就要考虑到related模块 和 upsell模块谁先加载问题 结果证明 content 中的upsell模块先加载(这个加载顺便貌似可以调整 暂时没研究)
所以先记录Mage::register("upsell_used_product_ids", $all_product_ids); 相关产品模块调用Mage::registry(‘upsell_used_product_ids‘);来过滤upsell中已经存在的产品
magento related/upsell product 及产品/分类调用
标签:
原文地址:http://www.cnblogs.com/weicot-com/p/4632286.html