Skip to content

Commit

Permalink
ENGCOM-1414: FIX for issue#14869 - Wrong price at backend after update
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirZaets authored May 2, 2018
2 parents e38d8c7 + e610b72 commit 3e4f5b7
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionContro
*/
protected $_quoteConfig;

/**
* @var \Magento\Store\Model\StoreManagerInterface|null
*/
private $storeManager;

/**
* @param \Magento\Framework\Data\Collection\EntityFactory $entityFactory
* @param \Psr\Log\LoggerInterface $logger
Expand All @@ -56,6 +61,7 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\VersionContro
* @param \Magento\Quote\Model\Quote\Config $quoteConfig
* @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
* @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource
* @param \Magento\Store\Model\StoreManagerInterface|null $storeManager
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -68,7 +74,8 @@ public function __construct(
\Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory,
\Magento\Quote\Model\Quote\Config $quoteConfig,
\Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
\Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null,
\Magento\Store\Model\StoreManagerInterface $storeManager = null
) {
parent::__construct(
$entityFactory,
Expand All @@ -82,6 +89,10 @@ public function __construct(
$this->_itemOptionCollectionFactory = $itemOptionCollectionFactory;
$this->_productCollectionFactory = $productCollectionFactory;
$this->_quoteConfig = $quoteConfig;

// Backward compatibility constructor parameters
$this->storeManager = $storeManager ?:
\Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Store\Model\StoreManagerInterface::class);
}

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

/**
Expand Down

0 comments on commit 3e4f5b7

Please sign in to comment.