3

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();
        }

1 Answer 1

7

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

1
  • 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, 2017 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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