我在我的Observer文件夾中有一個公共功能。 (我用它來瀏覽圖像),但事情是,我不想使用'法師:: app() - > setCurrentStore()'Magento替代setCurrentStore()
什麼是替代瀏覽給定商店沒有使用setCurrentStore()?
function getImages($store, $v){
Mage::app()->setCurrentStore($store);
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToSelect('name');
foreach($products as $product) {
$images = Mage::getModel('catalog/product')->load($product->getId())->getMediaGalleryImages();
if($images){
$i2=0; foreach($images as $image){ $i2++;
$curr = Mage::helper('catalog/image')->init($product, 'image', $image->getFile())->resize(265).'<br>';
}
}
}
}
foreach (Mage::app()->getWebsites() as $website) {
foreach ($website->getGroups() as $group) {
$stores = $group->getStores();
foreach ($stores as $store) {
getImages($store, $i);
$i++;
}
}
}
PS: 如果我使用setCurrentStore()我的管理員搞砸了:-S
太棒了,這就是我一直在尋找的! – 2013-02-24 19:44:12
額外的好處:這模擬了前端 - 這意味着你在它內部使用的所有相關引用(例如,任何皮膚或設計文件,如css,phtml,js等)都是相對於前端根目錄的 - 所以你可以使用在BACKEND上顯示app_emulation,以顯示通常只在FRONTEND – Benubird 2013-03-28 09:31:42
可見的塊。感謝它的運作。你是一個拯救生命的人:) – deanpodgornik 2015-02-26 14:38:51