概要
我想通过SKU加载产品,有很多文章,博客文章,堆栈溢出结果等。我只想知道-为什么通过SKU加载产品必须如此困难?
// This method does not work (Of all, I expect this to work)
$product = Mage::getModel('catalog/product')->loadBySku($sku);
// These do not work either
$product = Mage::getModel('catalog/product')->loadByAttribute($sku, 'sku');
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
// This does not work
$product = Mage::getModel('catalog/product')->load($sku, 'sku');
当然,我现在对Magento期望simple
做的事情太多了(简单是Magento显然不熟悉的概念)
// This works:
$product = Mage::getModel('catalog/product');
$product->load($product->getIdBySku($sku));