Magento 具有扁平目录类别/产品的setPostedProducts
我正在使用setPostedProducts来维护销售/折扣类别。 在我的开发机器上,它的工作平台目录类别和产品是关闭的。 在我的舞台机器平面目录类别和产品上,它不再工作了 我怎样才能解决这个问题Magento 具有扁平目录类别/产品的setPostedProducts,magento,magento-1.9,Magento,Magento 1.9,我正在使用setPostedProducts来维护销售/折扣类别。 在我的开发机器上,它的工作平台目录类别和产品是关闭的。 在我的舞台机器平面目录类别和产品上,它不再工作了 我怎样才能解决这个问题 category = Mage::getModel('catalog/category')->load($categoryId); // category id of my sales category $category->setPostedProducts(array(123 =>
category = Mage::getModel('catalog/category')->load($categoryId); // category id of my sales category
$category->setPostedProducts(array(123 => 1)); // product 123 should be the only one in my sales category for testing purposes
$category->save();
我真的不知道为什么,但解决我问题的是添加
Mage::app('admin');
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
在执行setPostedProduct之前。
我假设在管理中,_getResource函数转换为Mage_Catalog_Model_Resource_Category而不是Mage_Catalog_Model_Resource_Category_Flat