尝试加载产品时,
$foundProduct = Mage::getModel('catalog/product')->load($sku, 'sku');
我们得到以下错误:
Fatal error:
Uncaught exception 'Exception' with message 'Warning: Invalid argument supplied for foreach()
in app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 954' in app/code/core/Mage/Core/functions.php:245 Stack trace:
#0 app/code/core/Mage/Eav/Model/Entity/Abstract.php(954): mageCoreErrorHandler(2, 'Invalid argumen...', '/var/www/magent...', 954, Array)
#1 app/code/core/Mage/Catalog/Model/Resource/Abstract.php(698): Mage_Eav_Model_Entity_Abstract->load(Object(Mage_Catalog_Model_Product), '120x180 ES-bale...', 'sku')
#2 app/code/core/Mage/Core/Model/Abstract.php(225): Mage_Catalog_Model_Resource_Abstract->load(Object(Mage_Catalog_Model_Product), '120x180 ES-bale...', 'sku')
#3 updatemagento.php(197): Mage_Core_Model_Abstract->load('120x180 ES-bale...', 'sku')
#4 {main} thrown in app/code/core/Mage/Core/functions.php on line 245
任何想法出什么事了吗?
loadByAttribute
使用集合并按给定属性进行过滤。这意味着,产品加载的观察者将不适用,并且您将没有库存,画廊等完整的数据load()
。