-
Notifications
You must be signed in to change notification settings - Fork 9.4k
MAGETWO-99236 Fix for #22063 Category data is changed after saving category linkfor different stores #34226
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
Open
ilnytskyi
wants to merge
18
commits into
magento:2.4-develop
Choose a base branch
from
ilnytskyi:product-link-fix2
base: 2.4-develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
MAGETWO-99236 Fix for #22063 Category data is changed after saving category linkfor different stores #34226
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dcc5db2
MAGETWO-99236 Fix for #22063
ilnytskyi a12a2b9
#22063 add test, fix failing test
ilnytskyi a814b6c
#22063 Improve Category repository, improve performance of saving lin…
ilnytskyi b1fd10d
#22063 static test fix
ilnytskyi f6d6f32
#22063 Static test fix
ilnytskyi 30f54bb
#22063 fix unit tests
ilnytskyi 7ee34dc
fixtures improve
ilnytskyi e10ae42
#22063 fix cache in category tests
ilnytskyi f4dc991
#22063 fix tests
ilnytskyi bf44d89
Merge branch '2.4-develop' into product-link-fix2
ilnytskyi f755d7f
Merge branch '2.4-develop' into product-link-fix2
ilnytskyi 3c607a6
Merge branch '2.4-develop' into product-link-fix2
ilnytskyi f21d658
Merge branch '2.4-develop' into product-link-fix2
ilnytskyi b1153ee
Merge branch '2.4-develop' into product-link-fix2
ilnytskyi ae08df9
Merge branch '2.4-develop' into product-link-fix2
ilnytskyi 9c23fe6
static
ilnytskyi 60b1dae
Merge branch '2.4-develop' into product-link-fix2
ilnytskyi 87c6d78
Merge branch 'refs/heads/2.4-develop' into product-link-fix2
ilnytskyi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
100 changes: 100 additions & 0 deletions
100
dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryLinkRepositoryTest.php
This file contains hidden or 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,100 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Model; | ||
|
||
use Magento\Catalog\Api\CategoryLinkRepositoryInterface; | ||
use Magento\Catalog\Api\CategoryRepositoryInterface; | ||
use Magento\Catalog\Api\Data\CategoryProductLinkInterface; | ||
use Magento\Framework\App\Area; | ||
use Magento\Store\Api\StoreRepositoryInterface; | ||
use Magento\Store\Model\App\Emulation; | ||
use Magento\Store\Model\Store; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
use Magento\TestFramework\ObjectManager; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class CategoryLinkRepositoryTest extends TestCase | ||
{ | ||
/** | ||
* @var ObjectManager | ||
*/ | ||
private $objectManager; | ||
|
||
/** | ||
* @var CategoryLinkRepositoryInterface | ||
*/ | ||
private $categoryLinkRepository; | ||
|
||
/** | ||
* @var CategoryRepositoryInterface | ||
*/ | ||
private $categoryRepository; | ||
|
||
/** | ||
* @var StoreRepositoryInterface | ||
*/ | ||
private $storeRepository; | ||
|
||
/** | ||
* @var Emulation | ||
*/ | ||
private $appEmulation; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->objectManager = Bootstrap::getObjectManager(); | ||
$this->categoryLinkRepository = $this->objectManager->get(CategoryLinkRepositoryInterface::class); | ||
$this->storeRepository = $this->objectManager->get(StoreRepositoryInterface::class); | ||
$this->categoryRepository = $this->objectManager->get(CategoryRepositoryInterface::class); | ||
$this->appEmulation = $this->objectManager->get(Emulation::class); | ||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* Make sure that if some custom code uses emulation and assigns products to categories, | ||
* the categories are not overwritten by loading data via category repository from wrong store. | ||
* The default store is used in | ||
* @see \Magento\Catalog\Model\CategoryLinkRepository::save | ||
* | ||
* @magentoAppArea crontab | ||
* @magentoDbIsolation disabled | ||
* @magentoDataFixture Magento/Catalog/_files/saving_product_category_link_under_different_stores.php | ||
*/ | ||
public function testCategoryDataNotChanged() | ||
{ | ||
$secondStore = $this->storeRepository->get('fixture_second_store'); | ||
$secondStoreId = (int)$secondStore->getId(); | ||
/** @var CategoryProductLinkInterface $categoryProductLink */ | ||
$categoryProductLink = $this->objectManager->create(CategoryProductLinkInterface::class); | ||
|
||
$this->appEmulation->startEnvironmentEmulation($secondStoreId, Area::AREA_FRONTEND, true); | ||
|
||
$categoryProductLink | ||
->setCategoryId(113) | ||
->setSku('simple116') | ||
->setPosition(2); | ||
|
||
$this->categoryLinkRepository->save($categoryProductLink); | ||
|
||
$this->appEmulation->stopEnvironmentEmulation(); | ||
|
||
$categoryFromDefaultStore = $this->categoryRepository->get(113); | ||
$categoryFromSecondStore = $this->categoryRepository->get(113, $secondStoreId); | ||
|
||
$categoryNameFromDefaultStore = $categoryFromDefaultStore->getName(); | ||
$categoryDescriptionFromDefaultStore = $categoryFromDefaultStore->getDescription(); | ||
|
||
$categoryNameFromSecondStore = $categoryFromSecondStore->getName(); | ||
$categoryDescriptionFromSecondStore = $categoryFromSecondStore->getDescription(); | ||
|
||
$this->assertEquals('Test Category In Default Store', $categoryNameFromDefaultStore); | ||
$this->assertEquals('Test description in default store', $categoryDescriptionFromDefaultStore); | ||
$this->assertEquals('Test Category In Second Store', $categoryNameFromSecondStore); | ||
$this->assertEquals('Test description in second store', $categoryDescriptionFromSecondStore); | ||
} | ||
} |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I googled a bit this class and it looks like there is not modules that add peference for it or replace this dependecy. Anyway they would preference the interface, so maybe it's worth to just delete the product repo from here and infrom about minor BIC changes in new release?
Just waiting for approval from the core team