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

Magneto 2.3 Fix Product::addImageToMediaGallery throws Exception #19354

Closed

Conversation

gelanivishal
Copy link
Contributor

Original Pull Request

#18951

Fixed Issues (if relevant)

  1. Product::addImageToMediaGallery throws Exception #6803: Product::addImageToMediaGallery throws Exception

Preconditions

Magento Version 2.2.6
PHP Version 7.1

Steps to reproduce

$product = $this->productFactory->create()
            ->setName($productName)
            ->setStatus($productStatus)
            ->setSku($productSku)
$product->setAttributeSetId($product->getDefaultAttributeSetId());

$product->addImageToMediaGallery($file, [
                'image',
                'small_image',
                'thumbnail',
            ], false, false);
$this->productRepository->save($product);

Expected result

Image gets added

Actual result

Exception gets thrown:

Notice: Undefined index: media_type in vendor/magento/module-catalog/Model/Product.php on line 2527

There's a workaround for this issue, using the Product::save method instead of the ProductRepositoryInterface::save method, but because it's a deprecated method I would like to avoid this.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-engcom-team
Copy link
Contributor

Hi @gelanivishal. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@sivaschenko
Copy link
Member

Changes to app/code/Magento/Catalog/Model/Product/Gallery/Processor.php and dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_image.php are already present in 2.3-develop

@magento-engcom-team magento-engcom-team added this to the Release: 2.3.1 milestone Nov 23, 2018
@magento-engcom-team
Copy link
Contributor

Hi @sivaschenko, thank you for the review.
ENGCOM-3545 has been created to process this Pull Request

@orlangur orlangur self-assigned this Nov 23, 2018
@orlangur
Copy link
Contributor

@gelanivishal please pay attention to what you're porting, these changes already delivered in #18952.

@orlangur orlangur closed this Nov 23, 2018
@csdougliss
Copy link
Contributor

@orlangur when is 2.3.1 released? I need this fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants