forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - magento#20328: [Backport] Fix issue 20232 : Backend order credit card detail check box misaligned (by @GovindaSharma) - magento#20325: [Backport] issus fixed magento#20158 Store switcher not aligned proper in tab view (by @shikhamis11) - magento#20353: Fixed#20352: displaying html content for file type option on order view admin area (by @maheshWebkul721) - magento#20329: [Backport] Product image failure when importing through CSV magento#20098 (by @irajneeshgupta) - magento#20298: ISSUE-20296: "@magentoDataIsolation" is used instead of "@magentoDbIsolation" in some integration tests. (by @p-bystritsky) - magento#20185: [Backport] Move website_name column into columnSet (by @mage2pratik) - magento#20286: [Backport] Don't return categoryId from registry if the product doesn't belong in the current category (by @GovindaSharma) - magento#20271: [Backport] Use the new json serializer which throws an error when failing (by @quisse) - magento#20183: 2.2 develop pr port 18888 (by @saphaljha) - magento#20178: magento#16198: Category image remain after deleted. (by @p-bystritsky) Fixed GitHub Issues: - magento#20232: Backend order credit card detail check box misaligned (reported by @speedy008) has been fixed in magento#20328 by @GovindaSharma in 2.2-develop branch Related commits: 1. 6c5cba7 - magento#20158: Store switcher not aligned proper in tab view (reported by @cedarvinda) has been fixed in magento#20325 by @shikhamis11 in 2.2-develop branch Related commits: 1. f9a03d8 2. 82ad1ca - magento#20352: File type option value shows html content in admin order view. (reported by @maheshWebkul721) has been fixed in magento#20353 by @maheshWebkul721 in 2.2-develop branch Related commits: 1. c0730dc - magento#20098: Product image failure when importing through CSV (reported by @flytomek) has been fixed in magento#20329 by @irajneeshgupta in 2.2-develop branch Related commits: 1. 40f64f9 - magento#20296: "@magentoDataIsolation" is used instead of "@magentoDbIsolation" in some integration tests. (reported by @p-bystritsky) has been fixed in magento#20298 by @p-bystritsky in 2.2-develop branch Related commits: 1. de64b09 - magento#17819: Wrong product url from getProductUrl when current category has not product object (reported by @OleksiiBulba) has been fixed in magento#20286 by @GovindaSharma in 2.2-develop branch Related commits: 1. 0247fc3 - magento#14937: Javascript error thrown from uiComponent 'notification_area' if messages are malformed (reported by @sylvainraye) has been fixed in magento#20271 by @quisse in 2.2-develop branch Related commits: 1. 7e3ea1b 2. f72fb42 3. dbb905c 4. c3f4d5d 5. 31bf4b2 - magento#18192: Backend issue : "ratings isn't available" website wise (reported by @hardik-krish) has been fixed in magento#20183 by @saphaljha in 2.2-develop branch Related commits: 1. 06443f9 2. cb6ff7e 3. 56a0f11 4. 9c59356 5. fd4dd39 6. a26b9bd 7. 30a6d5a - magento#16198: Category image remain after deleted (reported by @vincent2090311) has been fixed in magento#20178 by @p-bystritsky in 2.2-develop branch Related commits: 1. 3b4581c 2. 979e552
- Loading branch information
Showing
24 changed files
with
540 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/code/Magento/Catalog/Model/ResourceModel/Category/RedundantCategoryImageChecker.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Model\ResourceModel\Category; | ||
|
||
use Magento\Catalog\Api\CategoryListInterface; | ||
use Magento\Framework\Api\SearchCriteriaBuilder; | ||
|
||
/** | ||
* Check if Image is currently used in any category as Category Image. | ||
*/ | ||
class RedundantCategoryImageChecker | ||
{ | ||
/** | ||
* @var SearchCriteriaBuilder | ||
*/ | ||
private $searchCriteriaBuilder; | ||
|
||
/** | ||
* @var CategoryListInterface | ||
*/ | ||
private $categoryList; | ||
|
||
public function __construct( | ||
CategoryListInterface $categoryList, | ||
SearchCriteriaBuilder $searchCriteriaBuilder | ||
) { | ||
$this->categoryList = $categoryList; | ||
$this->searchCriteriaBuilder = $searchCriteriaBuilder; | ||
} | ||
|
||
/** | ||
* Checks if Image is currently used in any category as Category Image. | ||
* | ||
* Returns true if not. | ||
* | ||
* @param string $imageName | ||
* @return bool | ||
*/ | ||
public function execute(string $imageName): bool | ||
{ | ||
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */ | ||
$searchCriteria = $this->searchCriteriaBuilder->addFilter('image', $imageName)->create(); | ||
$categories = $this->categoryList->getList($searchCriteria)->getItems(); | ||
|
||
return empty($categories); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
app/code/Magento/Catalog/Plugin/Model/ResourceModel/Category/RemoveRedundantImagePlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Plugin\Model\ResourceModel\Category; | ||
|
||
use Magento\Catalog\Model\ImageUploader; | ||
use Magento\Catalog\Model\ResourceModel\Category as CategoryResource; | ||
use Magento\Catalog\Model\ResourceModel\Category\RedundantCategoryImageChecker; | ||
use Magento\Framework\App\Filesystem\DirectoryList; | ||
use Magento\Framework\Filesystem; | ||
use Magento\Framework\Model\AbstractModel; | ||
|
||
/** | ||
* Remove old Category Image file from pub/media/catalog/category directory if such Image is not used anymore. | ||
*/ | ||
class RemoveRedundantImagePlugin | ||
{ | ||
/** | ||
* @var Filesystem | ||
*/ | ||
private $filesystem; | ||
|
||
/** | ||
* @var ImageUploader | ||
*/ | ||
private $imageUploader; | ||
|
||
/** | ||
* @var RedundantCategoryImageChecker | ||
*/ | ||
private $redundantCategoryImageChecker; | ||
|
||
public function __construct( | ||
Filesystem $filesystem, | ||
ImageUploader $imageUploader, | ||
RedundantCategoryImageChecker $redundantCategoryImageChecker | ||
) { | ||
$this->filesystem = $filesystem; | ||
$this->imageUploader = $imageUploader; | ||
$this->redundantCategoryImageChecker = $redundantCategoryImageChecker; | ||
} | ||
|
||
/** | ||
* Removes Image file if it is not used anymore. | ||
* | ||
* @param CategoryResource $subject | ||
* @param CategoryResource $result | ||
* @param AbstractModel $category | ||
* @return CategoryResource | ||
* | ||
* @throws \Magento\Framework\Exception\FileSystemException | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterSave( | ||
CategoryResource $subject, | ||
CategoryResource $result, | ||
AbstractModel $category | ||
): CategoryResource { | ||
$originalImage = $category->getOrigData('image'); | ||
if (null !== $originalImage | ||
&& $originalImage !== $category->getImage() | ||
&& $this->redundantCategoryImageChecker->execute($originalImage) | ||
) { | ||
$basePath = $this->imageUploader->getBasePath(); | ||
$baseImagePath = $this->imageUploader->getFilePath($basePath, $originalImage); | ||
/** @var \Magento\Framework\Filesystem\Directory\WriteInterface $mediaDirectory */ | ||
$mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA); | ||
$mediaDirectory->delete($baseImagePath); | ||
} | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.