【问题标题】:Magento text field attribute's value collectionMagento 文本字段属性的值集合
【发布时间】:2014-02-08 10:39:36
【问题描述】:

在 Magento 中,我设置了一个名为“供应商”(文本字段类型)的产品属性。 我想获得所有供应商值的唯一集合。

【问题讨论】:

    标签: magento custom-attributes


    【解决方案1】:

    $attribute_value = $product->getVendor(); //对于供应商属性(类型文本字段)

    独特属性

    // specify the attribute code
    $attributeCode = 'vendor';
    
    // build and filter the product collection
    $products = Mage::getResourceModel('catalog/product_collection')
            ->addAttributeToFilter($attributeCode, array('notnull' => true))
            ->addAttributeToFilter($attributeCode, array('neq' => ''))
            ->addAttributeToSelect($attributeCode);
    
    // get all distinct attribute values
    $usedAttributeValues = array_unique($products->getColumnValues($attributeCode));
    

    【讨论】:

      【解决方案2】:

      请试试这个...........

       $Collection=Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('vendor')->groupByAttribute('vendor');
          foreach($Collection as $each)
          {
          echo "<br/>".$each['vendor'];
          }
      

      【讨论】:

        猜你喜欢
        • 2023-03-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-02
        • 1970-01-01
        • 1970-01-01
        • 2014-01-29
        相关资源
        最近更新 更多