Closed
Description
Preconditions
- Magento 2.2.0 CE
- PHP 7.024
Steps to reproduce
- 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>
- Create
\Vendor\Module\Model\Quote
object which extends\Magento\Quote\Model\Quote
. - 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
- The result will be an object of instance
Vendor\Module\Model\Quote
Actual result
- 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.
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.2 release lineThe issue has been fixed in 2.3 release lineGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentThe issue has been reproduced on latest 2.1 releaseThe issue has been reproduced on latest 2.2 releaseThe issue has been reproduced on latest 2.3 release