- Notifications
You must be signed in to change notification settings - Fork 9.4k
31253 default store breadcrumbs returned for products which in both root categories #31822
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
Merged
magento-devops-reposync-svc merged 10 commits into magento:2.4-develop from sasha19957099:31253_default_store_breadcrumbs_returned_for_products_which_in_both_root_categories May 30, 2022
Merged
Changes from all commits
Commits
Show all changes
10 commits Select commit Hold shift + click to select a range
f39a5d9 magento/magento2#31253:
sasha19957099 f9df4da magento/magento2#312:default store breadcrumbs returned for another s…
sasha19957099 7f93862 magento/magento2ce#31253:Default store (Root category A) breadcrumbs …
sasha19957099 e30e7af Merge branch '2.4-develop' into 31253_default_store_breadcrumbs_retur…
sasha19957099 b4767d6 magento/magento2#31252:default store breadcrumbs returned for product…
sasha19957099 670e027 Merge branch '2.4-develop' of https://github.com/magento/magento2 int…
engcom-Lima 626ff28 Merge branch '2.4-develop' of https://github.com/magento/magento2 int…
engcom-Lima e8cf253 [BUGFIX] - Static test fixes
engcom-Lima b9fd820 [TASK] - reverted change
engcom-Lima 95f9e7a Merge branch '2.4-develop' into 31253_default_store_breadcrumbs_retur…
ishakhsuvarov 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
109 changes: 109 additions & 0 deletions 109 dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/Product/ProductCategoriesTest.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,109 @@ | ||
| <?php | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | ||
| | ||
| declare(strict_types=1); | ||
| | ||
| namespace Magento\GraphQl\Catalog\Product; | ||
| | ||
| use Magento\TestFramework\TestCase\GraphQlAbstract; | ||
| | ||
| /** | ||
| * Test for product categories | ||
| */ | ||
| class ProductCategoriesTest extends GraphQlAbstract | ||
| { | ||
| /** | ||
| * @magentoApiDataFixture Magento/Catalog/_files/product_in_two_root_categories.php | ||
| */ | ||
| public function testProductCategoriesInDefaultStore(): void | ||
| { | ||
| $response = $this->graphQlQuery( | ||
| $this->getQuery('in-stock-product'), | ||
| [], | ||
| '', | ||
| ['Store' => 'default'] | ||
| ); | ||
| | ||
| $product = current($response['products']['items']); | ||
| $categories = $product['categories']; | ||
| | ||
| self::assertCount(1, $categories); | ||
| self::assertEquals('Category 1', $categories[0]['name']); | ||
| self::assertEquals('category-1', $categories[0]['url_path']); | ||
| self::assertEquals('category-1', $categories[0]['url_path']); | ||
| self::assertNull($categories[0]['breadcrumbs']); | ||
| } | ||
| | ||
| /** | ||
| * @magentoApiDataFixture Magento/Catalog/_files/product_in_two_root_categories.php | ||
| */ | ||
| public function testProductCategoriesInNonDefaultStore(): void | ||
| { | ||
| $response = $this->graphQlQuery( | ||
| $this->getQuery('in-stock-product'), | ||
| [], | ||
| '', | ||
| ['Store' => 'test_store_1'] | ||
| ); | ||
| | ||
| $product = current($response['products']['items']); | ||
| $categories = $product['categories']; | ||
| | ||
| self::assertCount(2, $categories); | ||
| self::assertEquals('Second Root Subcategory', $categories[0]['name']); | ||
| self::assertEquals('second-root-subcategory', $categories[0]['url_path']); | ||
| self::assertNull($categories[0]['breadcrumbs']); | ||
| self::assertEquals('Second Root Subsubcategory', $categories[1]['name']); | ||
| self::assertEquals('second-root-subcategory/second-root-subsubcategory', $categories[1]['url_path']); | ||
| self::assertCount(1, $categories[1]['breadcrumbs']); | ||
| self::assertEquals('Second Root Subcategory', $categories[1]['breadcrumbs'][0]['category_name']); | ||
| self::assertEquals(2, $categories[1]['breadcrumbs'][0]['category_level']); | ||
| } | ||
| | ||
| /** | ||
| * @magentoApiDataFixture Magento/Catalog/_files/product_in_two_root_categories.php | ||
| * @magentoApiDataFixture Magento/Store/_files/second_store.php | ||
| */ | ||
| public function testProductCategoriesInNotRelevantStore(): void | ||
| { | ||
| $response = $this->graphQlQuery( | ||
| $this->getQuery('in-stock-product'), | ||
| [], | ||
| '', | ||
| ['Store' => 'fixture_second_store'] | ||
| ); | ||
| | ||
| self::assertEmpty($response['products']['items']); | ||
| } | ||
| | ||
| /** | ||
| * Get query | ||
| * | ||
| * @param string $sku | ||
| * @return string | ||
| */ | ||
| private function getQuery(string $sku): string | ||
| { | ||
| return <<<QUERY | ||
| { | ||
| products(filter: { sku: { eq: "{$sku}"} }){ | ||
| items { | ||
| categories { | ||
| name | ||
| id | ||
| url_path | ||
| breadcrumbs { | ||
| category_id | ||
| category_name | ||
| category_level | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| QUERY; | ||
| } | ||
| } |
67 changes: 67 additions & 0 deletions 67 dev/tests/integration/testsuite/Magento/Catalog/_files/product_in_two_root_categories.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,67 @@ | ||
| <?php | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | ||
| | ||
| declare(strict_types=1); | ||
| | ||
| use Magento\Catalog\Api\CategoryRepositoryInterface; | ||
| use Magento\Catalog\Api\Data\ProductInterface; | ||
| use Magento\Catalog\Api\ProductRepositoryInterface; | ||
| use Magento\Catalog\Model\CategoryFactory; | ||
| use Magento\Catalog\Model\ResourceModel\Category\Collection; | ||
| use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory; | ||
| use Magento\Store\Api\WebsiteRepositoryInterface; | ||
| use Magento\TestFramework\Helper\Bootstrap; | ||
| use Magento\TestFramework\Workaround\Override\Fixture\Resolver; | ||
| | ||
| Resolver::getInstance()->requireDataFixture('Magento/Store/_files/store_with_second_root_category.php'); | ||
| Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_with_category.php'); | ||
| | ||
| $objectManager = Bootstrap::getObjectManager(); | ||
| $productRepository = $objectManager->get(ProductRepositoryInterface::class); | ||
| $websiteRepository = $objectManager->get(WebsiteRepositoryInterface::class); | ||
| $categoryRepository = $objectManager->get(CategoryRepositoryInterface::class); | ||
| $categoryCollectionFactory = $objectManager->get(CollectionFactory::class); | ||
| $categoryFactory = $objectManager->get(CategoryFactory::class); | ||
| | ||
| $defaultWebsiteId = $websiteRepository->get('base')->getId(); | ||
| $secondWebsiteId = $websiteRepository->get('test')->getId(); | ||
| | ||
| /** @var $categoryCollection Collection */ | ||
| $categoryCollection = $categoryCollectionFactory->create(); | ||
| $categoryCollection->addFieldToFilter('name', ['eq' => 'Second Root Category']); | ||
| $secondRootCategory = $categoryCollection->getFirstItem(); | ||
| | ||
| $subCategory = $categoryFactory->create(); | ||
| $subCategory | ||
| ->setName('Second Root Subcategory') | ||
| ->setParentId($secondRootCategory->getEntityId()) | ||
| ->setLevel(2) | ||
| ->setAvailableSortBy(['position', 'name']) | ||
| ->setDefaultSortBy('name') | ||
| ->setIsActive(true) | ||
| ->setPosition(1); | ||
| $subCategory = $categoryRepository->save($subCategory); | ||
| | ||
| $subSubCategory = $categoryFactory->create(); | ||
| $subSubCategory | ||
| ->setName('Second Root Subsubcategory') | ||
| ->setParentId($subCategory->getEntityId()) | ||
| ->setLevel(2) | ||
| ->setAvailableSortBy(['position', 'name']) | ||
| ->setDefaultSortBy('name') | ||
| ->setIsActive(true) | ||
| ->setPosition(1); | ||
| $subSubCategory = $categoryRepository->save($subSubCategory); | ||
| | ||
| /** @var $product ProductInterface */ | ||
| $product = $productRepository->get('in-stock-product'); | ||
| $product | ||
| ->setUrlKey('in-stock-product') | ||
| ->setWebsiteIds([$defaultWebsiteId, $secondWebsiteId]) | ||
| ->setCategoryIds( | ||
| [2, 333, $secondRootCategory->getEntityId(), $subCategory->getEntityId(), $subSubCategory->getEntityId()] | ||
| ); | ||
| $productRepository->save($product); | ||
12 changes: 12 additions & 0 deletions 12 .../integration/testsuite/Magento/Catalog/_files/product_in_two_root_categories_rollback.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,12 @@ | ||
| <?php | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use parametrized fixture format | ||
| /** | ||
| * Copyright © Magento, Inc. All rights reserved. | ||
| * See COPYING.txt for license details. | ||
| */ | ||
| | ||
| declare(strict_types=1); | ||
| | ||
| use Magento\TestFramework\Workaround\Override\Fixture\Resolver; | ||
| | ||
| Resolver::getInstance()->requireDataFixture('Magento/Store/_files/store_with_second_root_category_rollback.php'); | ||
| Resolver::getInstance()->requireDataFixture('Magento/Catalog/_files/product_with_category_rollback.php'); | ||
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.
Please use parametrized fixture format