Magento 为什么类别中的产品带有Mage::app(';default';),而不带有Mage::app(';admin';)?
我写了一个扩展,在这个扩展中,我需要一个类别的活动产品的计数 我用这个剪报按类别确定活性产品:Magento 为什么类别中的产品带有Mage::app(';default';),而不带有Mage::app(';admin';)?,magento,collections,count,categories,product,Magento,Collections,Count,Categories,Product,我写了一个扩展,在这个扩展中,我需要一个类别的活动产品的计数 我用这个剪报按类别确定活性产品: $return = Mage::getModel('catalog/category') ->load($category->getId()) ->getProductCollection() ->addAttributeToSelect('entity_id') ->addAttributeToFilte
$return = Mage::getModel('catalog/category')
->load($category->getId())
->getProductCollection()
->addAttributeToSelect('entity_id')
->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
->addAttributeToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->count();
如果我调用函数获取test.php中活动产品的计数
header('Content-Type: text/html; charset=utf-8');
require_once "app/Mage.php";
Mage::reset();
Mage::app('default');
var_dump(myDummyFunction($categoryObject));
结果我得了3分。如果我在扩展(用于管理区域)的同一magento中使用相同的函数,则结果为0
有人知道为什么会发生这种情况以及如何解决吗
顺便说一句:如果我更改Mage::app('default');在test.php到Mage::app('admin');它还显示0 用这个
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
就在这之前
Mage::app('default');
用这个
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
就在这之前
Mage::app('default');
使用此Mage::app()->setCurrentStore(Mage\u Core\u Model\u app::ADMIN\u STORE\u ID);就在Mage::app('default')之前;工作就像魅力。。。非常感谢你!Mage::app()->setCurrentStore(我的存储\u ID\u工作的位置);使用此Mage::app()->setCurrentStore(Mage\u Core\u Model\u app::ADMIN\u STORE\u ID);就在Mage::app('default')之前;工作就像魅力。。。非常感谢你!Mage::app()->setCurrentStore(我的存储\u ID\u工作的位置);