1

How to get product custom attribute in product grid. I have create product attribute as "qty_per_box". But it is not showing in collection.

The following code is not getting custom product attribue.

  /**
    * @return Grid
    */
        protected function _prepareCollection()
        {
            $collection = $this->productFactory->create()->getCollection()->addAttributeToSelect("*");
            $this->setCollection($collection);
            return parent::_prepareCollection();
        }
4

1/ Magento Admin > Stores > Attributes / Product > Click on your custom attribute > Advanced Attribute Properties > Set "Add to Column Options" to "Yes" and click on "Save attribute" button

enter image description here

2/ Magento Admin > Products > Inventory / Catalog > Select your custom attribute on "Columns box"

enter image description here

  • I am showing product grid in custom module. I have created product attribute as swatch option. In product gird it is returning the option value. But I want to get option text. – Abhishek Mar 1 '17 at 16:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.