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

#34437: include the store value in category list function #34979

Open
wants to merge 1 commit into
base: 2.4-develop
Choose a base branch
from

Conversation

makzef
Copy link

@makzef makzef commented Jan 18, 2022

Description (*)

Category list function receive categories which doesn't consider a store-view value. So the store-view dependent properties of category are the same for different stores. This PR is fixing it by including the current store to get correct values for each category in the list.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes \Magento\Catalog\Model\CategoryList::getList gets cached objects if iterating over stores #34437

Manual testing scenarios (*)

Manual testing was done according to reproduce steps.

  1. Should be multiple store views.
  2. Needed category, which has different name for each store view.
  3. try to get a category name for each store with \Magento\Catalog\Api\CategoryListInterface::getList()
    Modified code for test:
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $storeManagerInterface = $objectManager->create(\Magento\Store\Model\StoreManagerInterface::class);
        $emulation = $objectManager->create(\Magento\Store\Model\App\Emulation::class);
        
        $searchCriteriaBuilder = $objectManager->create(\Magento\Framework\Api\SearchCriteriaBuilder::class);
        $categoryList = $objectManager->create(\Magento\Catalog\Api\CategoryListInterface::class);
        $testCategoryId = 41;

        foreach ($storeManagerInterface->getStores() as $store) {
            $emulation->startEnvironmentEmulation($store->getId());

            $searchCriteria = $searchCriteriaBuilder->create();
            $categories = $categoryList->getList($searchCriteria);

            foreach ($categories->getItems() as $category) {
                if ($category->getId() == $testCategoryId) {
                    echo "Store Id: " . $store->getName() . ". Store Id: " . $category->getStoreId() . ". Store Name: " . $category->getName() . "</br>";
                }
            }
            
            $emulation->stopEnvironmentEmulation();
        }

        die;

Notice: $testCategoryId - shoud be Id of category with different names for each store view.
4. Check category names for different stores, they should be correct at this moment.

Questions or comments

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)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Jan 18, 2022

Hi @makzef. Thank you for your contribution
Here are 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 give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.

For more details, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-community-project m2-community-project bot added Priority: P3 May be fixed according to the position in the backlog. labels Jan 18, 2022
@makzef
Copy link
Author

makzef commented Jan 18, 2022

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

Copy link
Contributor

@nuzil nuzil left a comment

Choose a reason for hiding this comment

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

Can you please check failed tests? They are related to your changes

@makzef
Copy link
Author

makzef commented Jan 18, 2022

Can you please check failed tests? They are related to your changes

Sure thing, I see that and working on it.

@makzef
Copy link
Author

makzef commented Jan 19, 2022

@magento run Unit Tests, Static Tests, Functional Tests EE, Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

Copy link

@andrewbess andrewbess left a comment

Choose a reason for hiding this comment

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

Hello @makzef
Thank you for your contribution.
Please check my comments.

app/code/Magento/Catalog/Model/CategoryList.php Outdated Show resolved Hide resolved
app/code/Magento/Catalog/Model/CategoryList.php Outdated Show resolved Hide resolved
@makzef
Copy link
Author

makzef commented Jan 19, 2022

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@makzef
Copy link
Author

makzef commented Jan 20, 2022

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@coderimus
Copy link
Contributor

@magento run Unit Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@makzef
Copy link
Author

makzef commented Jan 20, 2022

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

2 similar comments
@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@makzef makzef force-pushed the 34437-category-list-across-stores branch 2 times, most recently from 067d3b4 to 05dbf74 Compare January 24, 2022 07:26
@makzef makzef force-pushed the 34437-category-list-across-stores branch from 05dbf74 to 196eebd Compare January 24, 2022 07:28
@makzef
Copy link
Author

makzef commented Jan 24, 2022

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@coderimus coderimus requested review from nuzil and andrewbess January 25, 2022 07:46
@coderimus coderimus self-assigned this Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Priority: P3 May be fixed according to the position in the backlog. Progress: review Release Line: 2.4
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

\Magento\Catalog\Model\CategoryList::getList gets cached objects if iterating over stores
5 participants