Magento 如何按门店获取产品价格过滤器
我正在尝试根据Magento中的商店Id获取产品价格。我正在使用以下代码:Magento 如何按门店获取产品价格过滤器,magento,magento-1.9,Magento,Magento 1.9,我正在尝试根据Magento中的商店Id获取产品价格。我正在使用以下代码: $store_id=2; $collection=Mage::getModel('catalog/product')->getCollection(); $collection->addAttributeToSelect(array('name','image', 'price','special_price', 'special_packing','prosort','description','speci
$store_id=2;
$collection=Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect(array('name','image', 'price','special_price', 'special_packing','prosort','description','special_from_date','special_to_date'))
->addStoreFilter($store_id)
->addAttributeToSort('position');
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
foreach($collection as $product){
$products = Mage::getModel('catalog/product')->load($product->getId());
print_r($products->getPrice());
}
但作为回报,我得到了默认价格,我有什么遗漏或做错了吗
谢谢你的帮助 尝试在getCollection之后使用setStoreId()而不是addStoreFilter
$collection = Mage::getModel('catalog/product')->getCollection()->setStoreId($store_id);
$collection->addAttributeToSelect(array('name','image', 'price','special_price', 'special_packing','prosort','description','special_from_date','special_to_date'))
这对我有用:
$store_id=2;
$collection=Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect(array('name','image', 'price','special_price', 'special_packing','prosort','description','special_from_date','special_to_date'))
->setStore($store_id)
->addAttributeToSort('position');
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
foreach($collection as $product){
$products = Mage::getModel('catalog/product')->load($product->getId());
print_r($products->getPrice());
}
真的吗??设置存储ID(我)不为我工作。我在扩展模型中使用了这个,知道吗?