-
-
Notifications
You must be signed in to change notification settings - Fork 452
Media Gallery behavior when duplicating a product: Keep/Skip product images #5083
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
base: main
Are you sure you want to change the base?
Conversation
…copy the images or not. added a configuration option “Skip Images on Duplicate” and a small prompt on Duplicate when the source product has images.
# Conflicts: # app/code/core/Mage/Catalog/Model/Product.php
|
| /** | ||
| * @return int | ||
| */ | ||
| public function skipProductImageOnDuplicate() | ||
| { | ||
| return Mage::getStoreConfigAsInt(self::XML_NODE_SKIP_IMAGE_ON_DUPLICATE_ACTION); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /** | |
| * @return int | |
| */ | |
| public function skipProductImageOnDuplicate() | |
| { | |
| return Mage::getStoreConfigAsInt(self::XML_NODE_SKIP_IMAGE_ON_DUPLICATE_ACTION); | |
| } | |
| public function skipProductImageOnDuplicate(): int | |
| { | |
| return Mage::getStoreConfigAsInt(self::XML_NODE_SKIP_IMAGE_ON_DUPLICATE_ACTION); | |
| } |
| * @return string | ||
| */ | ||
| public function getDuplicateUrl() | ||
| public function getDuplicateUrl($skipImages = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public function getDuplicateUrl($skipImages = false) | |
| public function getDuplicateUrl(bool $skipImages = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a new method getDuplicateSkipUrl()?
| /** | ||
| * Used when duplicating product | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $_skipImagesOnDuplicate = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /** | |
| * Used when duplicating product | |
| * | |
| * @var string | |
| */ | |
| protected $_skipImagesOnDuplicate = false; | |
| /** | |
| * Used when duplicating product | |
| */ | |
| protected bool $skipImagesOnDuplicate = false; |
| /** | ||
| * @param bool $newProductSkipImages | ||
| * @return $this | ||
| */ | ||
| public function setSkipImagesOnDuplicate(bool $newProductSkipImages){ | ||
| $this->_skipImagesOnDuplicate = $newProductSkipImages; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /** | |
| * @param bool $newProductSkipImages | |
| * @return $this | |
| */ | |
| public function setSkipImagesOnDuplicate(bool $newProductSkipImages){ | |
| $this->_skipImagesOnDuplicate = $newProductSkipImages; | |
| /** | |
| * @return $this | |
| */ | |
| public function setSkipImagesOnDuplicate(bool $newProductSkipImages) | |
| { | |
| $this->skipImagesOnDuplicate = $newProductSkipImages; |
| /** | ||
| * @return bool|string | ||
| */ | ||
| public function getSkipImagesOnDuplicate(){ | ||
| return $this->_skipImagesOnDuplicate; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /** | |
| * @return bool|string | |
| */ | |
| public function getSkipImagesOnDuplicate(){ | |
| return $this->_skipImagesOnDuplicate; | |
| } | |
| public function getSkipImagesOnDuplicate(): bool | |
| { | |
| return $this->skipImagesOnDuplicate; | |
| } |
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if($newProduct->getSkipImagesOnDuplicate() == null && $this->_getImageHelper()->skipProductImageOnDuplicate() === -1){ | ||
| $newProduct->setSkipImagesOnDuplicate(false); | ||
| }else{ | ||
| $newProduct->setSkipImagesOnDuplicate((bool) $this->_getImageHelper()->skipProductImageOnDuplicate()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if($newProduct->getSkipImagesOnDuplicate() == null && $this->_getImageHelper()->skipProductImageOnDuplicate() === -1){ | |
| $newProduct->setSkipImagesOnDuplicate(false); | |
| }else{ | |
| $newProduct->setSkipImagesOnDuplicate((bool) $this->_getImageHelper()->skipProductImageOnDuplicate()); | |
| } | |
| if (is_null($newProduct->getSkipImagesOnDuplicate()) && $this->_getImageHelper()->skipProductImageOnDuplicate() === -1) { # todo: use constant | |
| $newProduct->setSkipImagesOnDuplicate(false); | |
| } else { | |
| $newProduct->setSkipImagesOnDuplicate($this->_getImageHelper()->skipProductImageOnDuplicate()); | |
| } |
|
Much thanks. Please run phpcs-fixer and phpstan. Some errors should be fixed via suggestions. I'd add constants for options, of Please revert changes for trailing spaces. |



Description
I'm splitting up the work in 3 PRs after @addison74's comment in
Parts:
image,small_image,thumbnailattributesThis PR: Keep/Skip product images
System > Configuration > Catalog > Product Image > Skip Images on Duplicate(always ask, skip, keep)Questions or comments
Need help in adding tests