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

QuoteRepository get methods won't return CartInterface but Quote model #12802

Closed
msieprawski opened this issue Dec 19, 2017 · 6 comments
Closed
Assignees
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@msieprawski
Copy link

msieprawski commented Dec 19, 2017

Preconditions

  1. Magento 2.2.0 CE
  2. PHP 7.024

Steps to reproduce

  1. Create custom module with following etc/di.xml` file:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Quote\Api\Data\CartInterface" type="Vendor\Module\Model\Quote" />
</config>
  1. Create \Vendor\Module\Model\Quote object which extends \Magento\Quote\Model\Quote.
  2. Now execute following code:
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cartRepository = $objectManager->create(\Magento\Quote\Api\CartRepositoryInterface::class);
$cartRepository->get(70); // use existing quote ID

Expected result

  1. The result will be an object of instance Vendor\Module\Model\Quote

Actual result

  1. Actual result is an object of instance Magento\Quote\Model\Quote

It's caused by invalid vendor/magento/module-quote/Model/QuoteRepository.php::loadQuote method which uses Magento\Quote\Model\QuoteFactory in the very first line instead of Magento\Quote\Api\Data\CartInterfaceFactory.

The solution is to override QuoteRepository's loadQuote method and use CartInterfaceFactory.

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Dec 19, 2017
@msieprawski
Copy link
Author

Any updates on this one?

@magento-engcom-team magento-engcom-team added Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Feb 14, 2018
@magento-engcom-team
Copy link
Contributor

@msieprawski, thank you for your report.
We've acknowledged the issue and added to our backlog.

@cpjeanpaul
Copy link

So... ?

@Bartlomiejsz Bartlomiejsz self-assigned this Apr 3, 2019
@m2-assistant
Copy link

m2-assistant bot commented Apr 3, 2019

Hi @Bartlomiejsz. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 3. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 4. If the issue is not relevant or is not reproducible any more, feel free to close it.

Bartlomiejsz added a commit to Bartlomiejsz/magento2 that referenced this issue Apr 5, 2019
…Api\Data\CartInterface and return correct object from QuoteRepository (+4 squashed commits)

Squashed commits:
[55b9f3ec52b] Fix magento#12802 - fix phpmd, mark quoteFactory as deprecated
[56ca9a42468] Fix magento#12802 - change condition in quoteRepository
[734212812a4] Fix magento#12802 - revert change of constructor parameters names
[ba8ad543e0f] Fix magento#12802 - remove instanceof condition
@magento-engcom-team
Copy link
Contributor

Hi @msieprawski. Thank you for your report.
The issue has been fixed in #22149 by @Bartlomiejsz in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.2 release.

@magento-engcom-team magento-engcom-team added the Fixed in 2.3.x The issue has been fixed in 2.3 release line label Apr 29, 2019
magento-engcom-team added a commit that referenced this issue Apr 29, 2019
…face and return correct object from QuoteRepository #22149

 - Merge Pull Request #22149 from Bartlomiejsz/magento2:feature/fix_12802_quote_not_overridable
 - Merged commits:
   1. 865d7df
magento-engcom-team added a commit that referenced this issue Apr 29, 2019
…face and return correct object from QuoteRepository #22149

 - Merge Pull Request #22149 from Bartlomiejsz/magento2:feature/fix_12802_quote_not_overridable
 - Merged commits:
   1. 865d7df
   2. 6e079a3
   3. fa5cf90
magento-engcom-team pushed a commit that referenced this issue Apr 29, 2019
…face and return correct object from QuoteRepository #22149
Bartlomiejsz added a commit to Bartlomiejsz/magento2 that referenced this issue Apr 29, 2019
…Api\Data\CartInterface and return correct object from QuoteRepository (+4 squashed commits) Squashed commits: [55b9f3ec52b] Fix magento#12802 - fix phpmd, mark quoteFactory as deprecated [56ca9a42468] Fix magento#12802 - change condition in quoteRepository [734212812a4] Fix magento#12802 - revert change of constructor parameters names [ba8ad543e0f] Fix magento#12802 - remove instanceof condition
Bartlomiejsz added a commit to Bartlomiejsz/magento2 that referenced this issue Apr 29, 2019
…Api\Data\CartInterface and return correct object from QuoteRepository (+4 squashed commits) Squashed commits: [55b9f3ec52b] Fix magento#12802 - fix phpmd, mark quoteFactory as deprecated [56ca9a42468] Fix magento#12802 - change condition in quoteRepository [734212812a4] Fix magento#12802 - revert change of constructor parameters names [ba8ad543e0f] Fix magento#12802 - remove instanceof condition
@sidolov
Copy link
Contributor

sidolov commented May 7, 2019

Hi @msieprawski. Thank you for your report.
The issue has been fixed in #22549 by @Bartlomiejsz in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.10 release.

@sidolov sidolov added the Fixed in 2.2.x The issue has been fixed in 2.2 release line label May 7, 2019
magento-engcom-team added a commit that referenced this issue May 7, 2019
…r CartInterface and return correct object from QuoteRepository #22549

 - Merge Pull Request #22549 from Bartlomiejsz/magento2:2.2-develop-PR-port-22149
 - Merged commits:
   1. 2a148f6
   2. ac0e933
magento-engcom-team pushed a commit that referenced this issue May 7, 2019
…r CartInterface and return correct object from QuoteRepository #22549
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

5 participants