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
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI 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
It seems that you have set integer
as the backend_type
or type
property of your attribute. This is not possible. Normally you would use varchar
, if you want to store numbers, use int
or decimal
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 to eav_attribute
and catalog_eav_attribute
.
If you look, for example, into \Magento\Catalog\Setup\CategorySetup
, you will find that even here the type
attribute is written as the string "int". So, I guess it's totally fine if you do it like this in your own module.