脚本宝典收集整理的这篇文章主要介绍了php – Magento通过商店ID获取产品集合过滤器,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$store_id = Mage::app()->getStore()->getId(); $_testPRoductCollection = Mage::getResourceModel('reports/product_collection') ->setStoreid($storeId) ->addStoreFilter($store_id) ->addAttributeToSelect('*'); $_testproductCollection->load(); foreach($_testproductCollection as $_testproduct){ echo $this->htMLEscaPE($_testproduct->getName()); };
如果我打印商店ID,它给我正确的数字.我在第二家商店只有一种产品,那么为什么我从所有的商店中获得每个产品呢?我可以设置Main Store中的每个产品,不能在Store2中显示,然后添加一个可见性过滤器,但这将永远存在.
另外,我刚刚注意到,如果我回覆产品商店ID,我得到当前的ID,而不是分配给它的商店:
echo $_testproduct->getStoreId()
如何解决这个问题?
$counter = ""; /*$model=Mage::getModel('cataLOG/product')->setStoreId($post['stores']); $rootCategoryId = Mage::app()->getStore($post['stores'])->getRootCategoryId(); $products = $model->getCollection(); $products->addStoreFilter($post['stores']); $products->addAttributeToFilter('sku',array('nlike' => 'B%')); $products->addAttributeToFilter('status',1); $counter=$products->getData();*/ $model=Mage::getModel('catalog/product')->setStoreId($post['stores']); $category_model = Mage::getModel('catalog/category'); $rootCategoryId = Mage::app()->getStore($post['stores'])->getRootCategoryId(); $_category = $category_model->load($rootCategoryId); $all_child_categories = $category_model->getResource()->getAllChildren($_category); foreach($all_child_categories as $storecategories): $category = Mage::getModel('catalog/category')->load($storecategories); $products = $category->getProductCollection(); //echo "Category id is::".$storecategories."Products are::".count($products); //echo "<br/>"; foreach($products as $collection): $removecatindex = $collection->getData(); unset($removecatindex['cat_index_posITion']); $counter[] = $removecatindex; enDForeach; endforeach;
以上是脚本宝典为你收集整理的php – Magento通过商店ID获取产品集合过滤器全部内容,希望文章能够帮你解决php – Magento通过商店ID获取产品集合过滤器所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。