Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catalog Module UpgradeData to 2.1.3 breaks when cost attribute is deleted #7804

Closed
AirmanAJK opened this issue Dec 14, 2016 · 8 comments
Closed
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release

Comments

@AirmanAJK
Copy link

I just updated from CE 2.1.2 to CE 2.1.3

Upon running setup:upgrade, I received an error message on the command line:
Notice: Undefined index: attribute_id in /var/www/magento2/public_html/vendor/magento/module-catalog/Setup/UpgradeData.php on line 375.

This line of code occurs in a loop that attempts to update several attributes to a global scope. The attributes to be updated are: price, cost, and special_price.

The problem is that cost is a user-defined attribute, and I deleted it a long time ago. The loop should ensure that the attribute exists before attempting to update it.

The information I've provided should be more than enough to recognize the issue without even testing it:
'cost' is a user-defined attribute and can be deleted at will.
'cost' has a hardcoded update in an UpgradeData.php file.

Please don't ask me to edit this to conform to Magento's bug report conventions. I spent enough time getting this upgrade to work and tracking this bug down. I will not respond and this easy fix will be closed after 2 weeks due to no replies.

@dthampy dthampy added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Dec 14, 2016
@dthampy
Copy link
Contributor

dthampy commented Dec 14, 2016

Internal jira ticket - MAGETWO-62266 created.

@jvreeken
Copy link

I am having the exact same problem...

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

@jvreeken
Copy link

@AirmanAJK can you tell me how I can get around this for now? thanks!

@jvreeken
Copy link

@AirmanAJK I just removed cost in the array on line 371 of UpgradeData.php and ran the upgrade again and was able to get by for now... is this the same as what you did? will this have any consequence?

@AirmanAJK
Copy link
Author

@jvreeken That's exactly right. This will not have any consequences assuming you deleted the cost attribute (which I'm sure you did since it crashed in the first place). I'm not aware of any other part of Magento that requires a cost attribute to function.

@sarathinyatnam
Copy link

sarathinyatnam commented Dec 21, 2016

Hey ,
I hope that correct solution will be that we can create the old attribute "cost" in the table eav_attribute by using the 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);

Then pls check the attribute_id of the "cost" and use it for creating another table entry in "catalog_eav_attribute" by using the query

INSERT INTO catalog_eav_attribute (attribute_id, frontend_input_renderer, is_global, is_visible, is_searchable, is_filterable, is_comparable, is_visible_on_front, is_html_allowed_on_front, is_used_for_price_rules, is_filterable_in_search, used_in_product_listing, used_for_sort_by, apply_to, is_visible_in_advanced_search, position, is_wysiwyg_enabled, is_used_for_promo_rules, is_required_in_admin_store, is_used_in_grid, is_visible_in_grid, is_filterable_in_grid, search_weight, additional_data) VALUES
(81, NULL, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 'simple,virtual,downloadable', 0, 0, 0, 0, 0, 1, 0, 1, 1, NULL);

pls use the attribute_id of cost instead of 81 .

the run the setup upgrade hope it will work fine.
if you have different deployment stage use install script for running the above query

Thanks

magento-team pushed a commit that referenced this issue Mar 15, 2017
magento-team pushed a commit that referenced this issue Mar 15, 2017
Bugs
- MAGETWO-65308 CLI command config:set fails on configurations which requires session
- MAGETWO-62560 Catalog Module UpgradeData to 2.1.3 breaks when cost attribute is deleted #7804 - for 2.2.0
Task
- MAGETWO-65208 Store checksum for every section of configuration file & change behavior on read-only FS & add sorting of importers
@veloraven
Copy link
Contributor

This issue was fixed in develop branch,
Internal ticket for ver. 2.1 - MAGETWO-62266

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@AirmanAJK, thank you for your report.
The issue is already fixed in 2.2.0

@magento-engcom-team magento-engcom-team added 2.1.x Fixed in 2.2.x The issue has been fixed in 2.2 release line Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release labels Sep 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Fixed in 2.2.x The issue has been fixed in 2.2 release line Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release
Projects
None yet
Development

No branches or pull requests

6 participants