-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Can't update products attribute in CLI #5414
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
Comments
Now after i've fixed the visibility of products in frontend (catalog search index didn't pass probably, changed mysql settings) the "CouldNotSave" exception from above is gone. Instead i get this now:
Which means the code above creates a huge data set which is not chunked and therefore way too large for mysql to handle it, right? Any ideas how to get around? |
I've tweaked the wait_timeout setting in my mysql config which "fixed" the exception "Error while sending QUERY packet". Now it's
again... |
you are setting the area to 'admin'. does it work if you set it to 'adminhtml'? |
@bh-ref well, seems like AreaCode should be 'adminhtml', but it doesn't fixes the Magento\Framework\Exception\LocalizedException from above (which stops setup:upgrade from working). The main issue is saving the product's attribute change where i still struggle. |
my experiments with using the productrepository in a script to use it to change attribute values on many products (just like you are trying) was very disappointing. I use different store views (for different languages), and the get messed up when I used the productrepository. what I am doing now is using the import mechanism to change attribute values, it does not seem to have these nasty side effects. there are two ways of doing it. first way: you prepare the csv file with the minimum required fields (you have to experiment a little) second way: you are simulating a csv by using arrays with this module: https://github.com/firegento/FireGento_FastSimpleImport2. maybe you should start with csv first. go to admin -> system -> import, choose product import and download the example csv and experiment with that. |
@bh-ref thanks for the hints! Is there no chance to get it work? |
I can feel your pain ;) it should be easy to do these things, I know, but I didn't managed it to do it by code without nasty side effects. another way would be to use SQL (I know, I know). by the way, the import does not need all fields for existing products. I think |
Good to know that someone else went through this hell also :) In Magento there was a very performant way of doing this:
|
it's frustrating, and since magento is now overhelmed with issues, you have to wait quite a bit for an answer. I did not work with magento 1 too much, but that was sure a nice and simple way to do it. if you go for SQL, this may help: http://magento-quickies.alanstorm.com/post/144213777050/running-arbitrary-sql-in-magento-2-like-an good luck with fixing your problem :) |
I'll try a bit more... seems like the product's ResourceModel got a saveAttribute function... |
if you come up with a working solution like that I eager to hear it. fingers crossed ;) |
@bh-ref the solution is right above! ;) The issue with the AreaCode is still there, but i don't care... this command is just a temporarily fix option. |
thanks for posting back, I will give it a shot if I come across a similar problem next time |
There is another issue with directives... so even when i got the solution now i can't use it. |
Steps to reproduce
2.1
branch.Expected result
Actual result
" [Magento\Framework\Exception\CouldNotSaveException]
Unable to save product "
Furthermore
IF AreaCode is set as state the command "works" but setup:upgrade doesn't works anymore:
"[Magento\Framework\Exception\LocalizedException]
Area code already set"
IF AreaCode is not set, the command doesn't work:
"[Magento\Framework\Exception\SessionException]
Area code not set: Area code must be set before starting a session."
"[Magento\Framework\Exception\LocalizedException]
Area code is not set "
But setup:upgrade works again.
How can i have both working as expected?!
The text was updated successfully, but these errors were encountered: