I created custom product attributes in custom module. when Add new product is clicked it shows this error message.
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento2_dev.catalog_product_entity_integer' doesn't exist
magento2
I created custom product attributes in custom module. when Add new product is clicked it shows this error message.
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento2_dev.catalog_product_entity_integer' doesn't exist
Best Answer
It seems that you have set
integer
as thebackend_type
ortype
property of your attribute. This is not possible. Normally you would usevarchar
, if you want to store numbers, useint
ordecimal
if you want to store prices or weight.You can find the types mentioned in the table
eav_attribute
.UPDATE
While you are totally correct that you prefer class constants over strings, imho this does not apply here.
\Magento\Framework\DB\Ddl\Table::TYPE_INTEGER
should be used when you create or modify columns of a database table. This is not the case, though, when you create a product attribute. This does not change any table structure, but only adds a new row toeav_attribute
andcatalog_eav_attribute
.If you look, for example, into
\Magento\Catalog\Setup\CategorySetup
, you will find that even here thetype
attribute is written as the string "int". So, I guess it's totally fine if you do it like this in your own module.