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

Magento 2.2 Fix Product::addImageToMediaGallery throws Exception #18951

Merged
merged 2 commits into from
Nov 22, 2018
Merged

Magento 2.2 Fix Product::addImageToMediaGallery throws Exception #18951

merged 2 commits into from
Nov 22, 2018

Conversation

progreg
Copy link
Contributor

@progreg progreg commented Oct 30, 2018

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)

@progreg progreg added Component: Catalog Fixed in 2.2.x The issue has been fixed in 2.2 release line labels Oct 30, 2018
@progreg progreg self-assigned this Oct 30, 2018
@magento-engcom-team
Copy link
Contributor

Hi @progreg. 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 $VERSION instance - deploy vanilla Magento instance

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

@progreg progreg removed the Fixed in 2.2.x The issue has been fixed in 2.2 release line label Oct 30, 2018
@orlangur orlangur assigned orlangur and unassigned progreg Oct 30, 2018
@orlangur
Copy link
Contributor

@progreg please rewrite branch history as cherry-picks of corresponding 2.3 commits, for example, composer.json is unintentionally changed now.

@progreg
Copy link
Contributor Author

progreg commented Nov 19, 2018

@orlangur, I did force push to remove old commits, and all related changes from 2.3 were applied as a patch. Is it will be enough?

Copy link
Contributor

@orlangur orlangur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@progreg yeah, should be fine as you're the author 👍 Please make similar squashing for 2.3 PR next time, then it would be perfect)

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

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

@progreg
Copy link
Contributor Author

progreg commented Nov 19, 2018

@orlangur, Ok, thanks for the advice :)

@magento-engcom-team
Copy link
Contributor

Hi @progreg. Thank you for your contribution.
We will aim to release these changes as part of 2.2.8.
Please check the release notes for final confirmation.

Please, consider to port this solution to 2.3 release line.
You may use Porting tool to port commits automatically.

@diazwatson
Copy link
Contributor

Does not need to be ported as code already is in 2.3-develop

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.

4 participants