Quantcast
Channel: Webkul Blog
Viewing all articles
Browse latest Browse all 5556

Custom product attributes with Source model not getting added to Flat table in Magento 2

$
0
0

Let’s suppose you created an drop down type custom product attribute which has a source model as in Create drop down product attribute in Magento 2 blog.

Even when we set used_in_product_listing=1 the attribute “attribute_code” will not be added to the flat table because we are using source model for this attribute.

So to add this attribute to the flat table we need to implement a method in Company\Module\Model\Config\Source\Options class as shown below,

public function getFlatColumns()
 {
     return ['attribute_code'=>['type'=>'integer', 'length'=>2]];
 }

Thank you for reading the blog. Please let me know by commenting if you face any issue.
Happy Coding 👨‍💻


Viewing all articles
Browse latest Browse all 5556

Latest Images

Trending Articles



Latest Images