【问题标题】:Load all Magento product attributes for array of ids加载 ID 数组的所有 Magento 产品属性
【发布时间】:2015-03-12 06:58:12
【问题描述】:

我有一个包含大约 15 个产品 ID 的数组,我想加载所有这 15 个产品的所有属性。 使用

$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*' )->addAttributeToFilter('entity_id', array('in' => $arrProductIdsToLoad ))->load();

仅返回具有存储在 product_flat 表中的属性的产品。

有没有办法一次加载一组产品 ID 的所有属性?我不想在平面表中添加所有需要的值。 我正在使用 Magento 1.8 CE。

感谢任何帮助

【问题讨论】:

    标签: magento


    【解决方案1】:

    试试这样:

    $p_id = 18;
    $product = Mage::getModel('catalog/product')->load($p_id);
    $product_attributes = $product->getAttributes();
    
    foreach ($product_attributes as $attribute) {       
        $attributeCode = $attribute->getAttributeCode();
        $label = $attribute->getStoreLabel($product);   
        $value = $attribute->getFrontend()->getValue($product);
        echo $attributeCode . '-' . $label . '-' . $value; echo "<br />";       
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多