My magento current version is 2.1.2 and upgraded with Composer by following command:

composer require magento/product-community-edition 2.1.3 --no-update
composer update
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento setup:upgrade

I'm getting following error while run command php bin/magento setup:upgrade

[Exception] Notice: Undefined index: attribute_id in vendor\magento\module-catalog\Setup\UpgradeData. php on line 375

Please help me for solve this error.


Your error comes from this method:

 * @param \Magento\Catalog\Setup\CategorySetup $categorySetup
 * @return void
private function changePriceAttributeDefaultScope($categorySetup)
    $entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
    foreach (['price', 'cost', 'special_price'] as $attributeCode) {
        $attribute = $categorySetup->getAttribute($entityTypeId, $attributeCode);
/*375*/     $attribute['attribute_id'],


The feasible issue is the absence of the attribute from the list ['price', 'cost', 'special_price'] in your system. Maybe you’ve deleted one of them?

You can find all of them in the table eav_attribute usin the query:

SELECT * FROM `eav_attribute` WHERE `attribute_code` IN ('price', 'cost', 'special_price')

You should see something similar to this:

query result

If you want to restore your cost attribute use this query:

INSERT INTO eav_attribute (entity_type_id, attribute_code, attribute_model, backend_model, backend_type, backend_table, frontend_model, frontend_input, frontend_label, frontend_class, source_model, is_required, is_user_defined, default_value, is_unique, note) VALUES (4, 'cost', null, 'Magento\\Catalog\\Model\\Product\\Attribute\\Backend\\Price', 'decimal', null, null, 'price', 'Cost', null, null, 0, 1, null, 0, null);
  • hey,thank you so much actually at my side "cost" attribute not exist so getting this error.I solved this error by adding if condition above $categorySetup->updateAttribute. – Sneha Panchal Dec 20 '16 at 12:24
  • 1
    @SnehaPanchal I was glad to help you. I recommend you to restore a system attribute to prevent other errors later. – Siarhey Uchukhlebau Dec 20 '16 at 12:28
  • But how can i restore? – Sneha Panchal Dec 20 '16 at 12:36
  • @SnehaPanchal I added the query to my answer, please try it. – Siarhey Uchukhlebau Dec 20 '16 at 12:57
  • 2
    You need to make one more insert statement. See this answer - github.com/magento/magento2/issues/7804#issuecomment-268457430 – Arvind07 Feb 19 '17 at 6:07

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.