Skip to content

Commit cf0507e

Browse files
author
Stanislav Idolov
authored
ENGCOM-2482: [Forwardport] FIX for issue#14869 - Wrong price at backend after update #16893
2 parents 9909d00 + cc76335 commit cf0507e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionContro
4545
*/
4646
protected $_quoteConfig;
4747

48+
/**
49+
* @var \Magento\Store\Model\StoreManagerInterface|null
50+
*/
51+
private $storeManager;
52+
4853
/**
4954
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
5055
* @param \Psr\Log\LoggerInterface $logger
@@ -56,6 +61,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionContro
5661
* @param \Magento\Quote\Model\Quote\Config $quoteConfig
5762
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
5863
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
64+
* @param \Magento\Store\Model\StoreManagerInterface|null $storeManager
5965
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
6066
*/
6167
public function __construct(
@@ -68,7 +74,8 @@ public function __construct(
6874
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
6975
\Magento\Quote\Model\Quote\Config $quoteConfig,
7076
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
71-
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
77+
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null,
78+
\Magento\Store\Model\StoreManagerInterface $storeManager = null
7279
) {
7380
parent::__construct(
7481
$entityFactory,
@@ -82,6 +89,10 @@ public function __construct(
8289
$this->_itemOptionCollectionFactory = $itemOptionCollectionFactory;
8390
$this->_productCollectionFactory = $productCollectionFactory;
8491
$this->_quoteConfig = $quoteConfig;
92+
93+
// Backward compatibility constructor parameters
94+
$this->storeManager = $storeManager ?:
95+
\Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Store\Model\StoreManagerInterface::class);
8596
}
8697

8798
/**
@@ -101,7 +112,10 @@ protected function _construct()
101112
*/
102113
public function getStoreId()
103114
{
104-
return (int)$this->_productCollectionFactory->create()->getStoreId();
115+
// Fallback to current storeId if no quote is provided
116+
// (see https://github.com/magento/magento2/commit/9d3be732a88884a66d667b443b3dc1655ddd0721)
117+
return $this->_quote === null ?
118+
(int) $this->storeManager->getStore()->getId() : (int) $this->_quote->getStoreId();
105119
}
106120

107121
/**

0 commit comments

Comments
 (0)