Update Magento 2.1.2 for 2.1.3 : Undefined index issue
-
05-10-2020 - |
سؤال
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);
$categorySetup->updateAttribute(
$entityTypeId,
/*375*/ $attribute['attribute_id'],
'is_global',
\Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL
);
}
}
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:
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);
لا تنتمي إلى magento.stackexchange