1

I Have a custom table that saves product attribute Id. For E.g

id, color_id, brand_id
1,123,122

Now I wanted to show attribute option value( Color name, brand name) on Admin grid of custom module.

I have added new columns in _initSelect() function in collection.php file as follow.

$this->getSelect()->columns(array(
         'brand' => new \Zend_Db_Expr('(select value from eav_attribute_option_value where  option_id = brand_id)')
     ));
$this->getSelect()->columns(array(
         'color' => new \Zend_Db_Expr('(select value from eav_attribute_option_value where  option_id = color_id)')
     ));

But, After adidng above I am not getting values in grid.

<column name="brand">
    <settings>
        <filter>text</filter>
        <label translate="true">Brand</label>
        <editor>
            <editorType>text</editorType>
            <validation>
                <rule name="required-entry" xsi:type="boolean">false</rule>
            </validation>
        </editor>
    </settings>
</column>

<column name="color">
    <settings>
        <filter>text</filter>
        <label translate="true">Brand</label>
        <editor>
            <editorType>text</editorType>
            <validation>
                <rule name="required-entry" xsi:type="boolean">false</rule>
            </validation>
        </editor>
    </settings>
</column>

How can we display name instead of attribute Id in grid?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.