我正在尝试以编程方式清除自定义模块中产品的组价格。这是我的代码:

Mage::setIsDeveloperMode(true); // for debug only
try
{
    $product = Mage::getModel('catalog/product')->load($productId);
    $product->setGroupPrice(null);
    $product->save();
}
catch (Exception $ex)
{
    echo "Error: ". $ex->getMessage();
}

当这段代码执行时,我得到以下异常:

警告:在/home/www-data/public_html/app/code/core/mage/mage/eav/model/entity/Entity/AbsTract.php上提供了无效的论点。

在里面 system.log 文件中,我看到分配了这些条目:

2016-03-17T18:01:06+00:00 错误 (3):警告:在/home/www-data/public_html/app/code/core/mage/mage/eav/model/entity/Ettity/AbsTract.php上,在/home/www-data/public_html/public_html/public_html/public_html/public_html/public_html/public_html/model/model/entity/abstract.php上提供了无效的论点err(3):可恢复的错误:Argument 3 passed to Mage_Catalog_Model_Resource_Abstract::_canUpdateAttribute() must be of the type array, null given, called in /home/www-data/public_html/app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 1225并在/home/www-data/public_html/app/code/core/mage/mage/catalog/model/model/resource/absorce/abstract.php上543 2016-03-17T18:01:01:06+00:00 err(3) :可恢复的错误:参数3传递给mage_eav_model_entity_abstract :: _ canupdateattribute()必须是类型阵列,null给定的,in/home/wwwwwwwwwwwwwwwwata/public_html/public_html/code/code/code/core/core/mage/mage/mage/mage/catalog/catalog/model/model/resource/resource/phptreats一下545并在/home/www-data/public_html/app/code/core/mage/eav/model/entity/entity/abstract.php上行驶1254 2016-03-17T18:01:01:06+00:00 ERR(3) :警告:array_key_exists()期望参数2为array,null,null/www-data/public_html/app/code/core/mage/mage/eav/eav/model/entity/Entity/Abstract.php on Line 1256 on Line 1256

知道是什么原因造成的吗?相同的代码在我的开发 magento 设置中可以工作,但是在生产 magento 中,这个错误开始出现,所以我有点困惑。

有帮助吗?

解决方案

您可能已经解决了这个问题,但对于其他寻求解决方案的人来说 - 您需要首先设置商店范围。

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
许可以下: CC-BY-SA归因
scroll top