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

Item resolvers should be optional #30823

Merged
merged 2 commits into from
Apr 11, 2021

Conversation

thomas-kl1
Copy link
Member

@thomas-kl1 thomas-kl1 commented Nov 6, 2020

Item resolvers should be optional. If we remove configurable and grouped product, checkout is broken because this argument is mandatory. Only the grouper and configurable product add item resolver.

Resolved issues:

  1. resolves [Issue] Item resolvers should be optional #30860: Item resolvers should be optional

Preconditions (*)

  1. Customer created
  2. Simple Product created

Steps to reproduce (*)

  1. Execute:
bin/magento module:disable Magento_GroupedImportExport
bin/magento module:disable Magento_GroupedCatalogInventory
bin/magento module:disable Magento_GroupedProductGraphQl
bin/magento module:disable Magento_MsrpGroupedProduct
bin/magento module:disable Magento_GroupedProduct
bin/magento module:disable Magento_CatalogRuleConfigurable
bin/magento module:disable Magento_MsrpConfigurableProduct
bin/magento module:disable Magento_NewRelicReporting
bin/magento module:disable Magento_ConfigurableProductGraphQl
bin/magento module:disable Magento_ConfigurableProductSales
bin/magento module:disable Magento_ConfigurableImportExport
bin/magento module:disable Magento_SwatchesGraphQl
bin/magento module:disable Magento_Swatches
bin/magento module:disable Magento_ConfigurableProduct
bin/magento setup:upgrade
  1. Login on storefront.
  2. Add Simple Product to cart.
  3. Go to Checkout.
  4. Create an Order.

@m2-assistant
Copy link

m2-assistant bot commented Nov 6, 2020

Hi @thomas-kl1. Thank you for your contribution
Here is 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

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, 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, please 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

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Nov 9, 2020

Hi @thomas-kl1,
Could you add some steps to reproduce, actual and expected result?
Unfortunately it's not clear how to important to fix the issue and if your solution is correct.

@m2-community-project m2-community-project bot moved this from Review in Progress to Changes Requested in Pull Requests Dashboard Nov 9, 2020
@thomas-kl1
Copy link
Member Author

Take a look on the implementation of the method:

/**
 * {@inheritdoc}
 */
public function getFinalProduct(ItemInterface $item) : ProductInterface
{
    $finalProduct = $item->getProduct();
    foreach ($this->itemResolvers as $resolver) {
        $resolvedProduct = $this->getItemResolverInstance($resolver)->getFinalProduct($item);
        if ($resolvedProduct !== $finalProduct) {
            $finalProduct = $resolvedProduct;
            break;
        }
    }
    return $finalProduct;
}

Default case should return the item product. Then it iterates over resolvers for specific type of products. However in this case it requires that itemResolvers is an array. But if the grouped and configurable products module is not there, it's breaking the checkout.. By design the catalog module should works regardless other product type implementation

@ihor-sviziev
Copy link
Contributor

@thomas-kl1 I see that in constructor we have defined type - array, so we shouldn't have any other options. Empty array should be by default.

Could you provide more info, what exception do you have? What value are you getting in the $itemResolvers are you getting when the grouped and configurable products module is not there?

@thomas-kl1
Copy link
Member Author

I got this: Invalid argument supplied for foreach(), value is null

@ihor-sviziev
Copy link
Contributor

Hi @thomas-kl1,
It doesn't seems to me logical.

Do you have some custom extension that changes this part? Could you provide full output of exception?

Still not clear where do you having this issue, on some frontend page or during some CLI command run?

@thomas-kl1
Copy link
Member Author

The issue occurs on the checkout and cart page. What does not seems logical there? You can edit composer json and replace both module, or create your own metapackage with magento2-base and catalog modules.
There is no third party modules. Only magento2 official modules

@ihor-sviziev
Copy link
Contributor

@thomas-kl1 thx for explanation, I'll check it myself and will give you my feedback a bit later.

@m2-community-project m2-community-project bot moved this from Changes Requested to Review in Progress in Pull Requests Dashboard Nov 9, 2020
@thomas-kl1
Copy link
Member Author

My bad I still had some debug trace. The actual error message was different and not that value null is used in foreach. I can post the actual exception later. Sorry

@m2-community-project m2-community-project bot moved this from Review in Progress to Changes Requested in Pull Requests Dashboard Nov 9, 2020
@thomas-kl1
Copy link
Member Author

Here the exception message:

[2020-11-06 16:04:57] main.CRITICAL: Missing required argument $itemResolvers of Magento\Catalog\Model\Product\Configuration\Item\ItemResolverComposite. [] []

@m2-community-project m2-community-project bot moved this from Changes Requested to Review in Progress in Pull Requests Dashboard Nov 9, 2020
@m2-community-project m2-community-project bot added the Priority: P3 May be fixed according to the position in the backlog. label Apr 8, 2021
@engcom-Foxtrot engcom-Foxtrot moved this from Ready for Testing to Extended Testing (optional) in High Priority Pull Requests Dashboard Apr 8, 2021
@engcom-Oscar engcom-Oscar added QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope and removed QA: Ready to add to Regression Scope Should be analyzed and added to Regression Testing Scope(if applicable) labels Apr 8, 2021
@m2-community-project m2-community-project bot moved this from Extended Testing (optional) to Ready for Testing in High Priority Pull Requests Dashboard Apr 8, 2021
@m2-community-project m2-community-project bot moved this from Extended Testing (optional) to Ready for Testing in High Priority Pull Requests Dashboard Apr 8, 2021
@engcom-Oscar engcom-Oscar moved this from Ready for Testing to Extended Testing (optional) in High Priority Pull Requests Dashboard Apr 8, 2021
@engcom-Foxtrot engcom-Foxtrot moved this from Extended Testing (optional) to Merge in Progress in High Priority Pull Requests Dashboard Apr 8, 2021
@ihor-sviziev ihor-sviziev removed the Priority: P3 May be fixed according to the position in the backlog. label Apr 8, 2021
@m2-community-project m2-community-project bot moved this from Merge in Progress to Ready for Testing in High Priority Pull Requests Dashboard Apr 8, 2021
@m2-community-project m2-community-project bot moved this from Ready for Testing to Merge in Progress in High Priority Pull Requests Dashboard Apr 8, 2021
@magento-engcom-team magento-engcom-team merged commit 59e3f71 into magento:2.4-develop Apr 11, 2021
@m2-assistant
Copy link

m2-assistant bot commented Apr 11, 2021

Hi @thomas-kl1, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@gabrieldagama gabrieldagama moved this from Merge in Progress to Recently Merged in High Priority Pull Requests Dashboard Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Award: bug fix Component: Catalog Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: accept QA: Added to Regression Scope Scenario was analysed and added to Regression Testing Scope Release Line: 2.4 Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it Type: Bug Fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Item resolvers should be optional
8 participants