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

After updating products from code, thumbnails are not showing in catalog and on backend #13262

Closed
erikkubica opened this issue Jan 18, 2018 · 10 comments
Assignees
Labels
Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@erikkubica
Copy link

Preconditions

  1. M2 v2.2.1
  2. Mysql 5.7
  3. PHP 7
  4. Ubuntu

Steps to reproduce

  1. Updated product stock and price using this code: https://pastebin.com/eytSENau
  2. Cleared cache, reindexed
  3. Thumbnails missing in product listing (category page) and in admin area too. Images on product_view page are visible and correct, images in product edit page in admin are also visible and correct.
  4. Tried to re-size images from command line, reindex, refresh cache.
  5. Still not visible

Expected result

  1. Images should be generated / loaded / recognized

Actual result

  1. Thumbnails on product listings are placeholders.

Color swatches and other images works, just the thumbnails not on product listings.

Any idea what can be the issue? It worked until i did not updated the products form code.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jan 18, 2018
@magento-engcom-team
Copy link
Contributor

@erikkubica The GitHub issue tracker is intended for technical issues only. Please refer to the Community Forums or the Magento Stack Exchange site for technical questions.

@erikkubica
Copy link
Author

erikkubica commented Jan 18, 2018

@magento-engcom-team Hi, i would like. But since after

$productRepository = $objectManager->get( '\Magento\Catalog\Model\ProductRepository' );
$product           = $productRepository->getById( $product->getId() );

$product->setName( $item->Nazov->__toString() );
$product->setPrice( floatval( $item->KonecnaCena->__toString() ) );
$product->setSpecialPrice(null); // Reset special price

$product->setStockData(['qty' => $_stock_qty, 'is_in_stock' => true]);
$product->setQuantityAndStockStatus(['qty' => $_stock_qty, 'is_in_stock' => true]);

$productRepository->save($product);

Thumbnails stop working, it seems like a magento bug since i am not even updating image related data..... which should be here. If it's correct Magento behavior, then it should be documented somewhere. But I was unable to find any "working" solution, and at the most of the solutions, it was a confirmed bug in M2 v2.1.6

@magento-engcom-team
Copy link
Contributor

magento-engcom-team commented Jan 18, 2018

@erikkubica, thanks for clarifying that.
We've acknowledged the issue and added to our backlog.

@magento-engcom-team magento-engcom-team added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed labels Jan 18, 2018
@erikkubica
Copy link
Author

@magento-engcom-team Seem like using $product->save(); instead of $productRepository->save($product); does not cause the issue.

@toddhainsworth
Copy link
Member

toddhainsworth commented May 16, 2018

Hi @magento-engcom-team @erikkubica,

Do either of you have an update on a fix to the ProductRepository? I believe we're experiencing the same issue after an upgrade to 2.2.3 and are currently trying to debug it.

Thanks

@erikkubica
Copy link
Author

Hey @toddhainsworth , IF I remember correctly the problem was with store_id of thumbnails after changing single store to multi store or vice versa. The same problem happened with setting tax_class from import. for some reason magento struggles with saving data to the correct store in some cases. But i am not 100% sure

@toddhainsworth
Copy link
Member

Thanks @erikkubica - hmm sounds plausible, appreciate the details! 😄
I'll provide some more information if I find anything worthwhile ✋

@peterlembke
Copy link

peterlembke commented Jun 13, 2018

Hi @erikkubica , do you have the media attributes intact? If not then this can help:

    protected function saveProduct($product, $setMediaGalleryToNull = true)
    {
        if ($setMediaGalleryToNull) {
            $product->setData('media_gallery', null); // Then we do not lose the media attributes,
            // bug https://github.com/magento/magento2/issues/10687
        }

        $this->_productRepository->save($product);
    }

@engcom-Delta engcom-Delta self-assigned this Dec 31, 2019
@m2-assistant
Copy link

m2-assistant bot commented Dec 31, 2019

Hi @engcom-Delta. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


@engcom-Delta engcom-Delta removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Dec 31, 2019
@engcom-Delta
Copy link
Contributor

engcom-Delta commented Dec 31, 2019

@erikkubica @toddhainsworth Unfortunately, I am not able to reproduce issue by steps you described on clean 2.4-develop
Steps to reproduce:

        $productRepository = ObjectManager::getInstance()->get(ProductRepository::class);
        $product           = $productRepository->getById( '1' );
        $product->setName('Test Prod');
        $product->setPrice( '500' );
        $product->setSpecialPrice(null); // Reset special price
        $productRepository->save($product);    

Actual result:
✔️ Image roles is not changed after updating products from code

Please feel free to comment, reopen or create new ticket according to the Issue reporting guidelines
if you are still facing this issue on the latest 2.4-develop branch. Thank you for collaboration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

5 participants