Skip to content

Commit

Permalink
Merge pull request #2669 from magento-tsg/2.2.5-develop-pr31
Browse files Browse the repository at this point in the history
[TSG] Backporting for 2.2 (pr31) (2.2.5)
  • Loading branch information
Alexander Akimov authored Jun 8, 2018
2 parents e959c78 + 9614c04 commit 8fc8439
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 22 deletions.
5 changes: 4 additions & 1 deletion app/code/Magento/CatalogRule/Model/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,10 @@ public function reindex()
$productIds = $this->_productIds ? array_keys(array_filter($this->_productIds, function (array $data) {
return array_filter($data);
})) : [];
$this->_ruleProductProcessor->reindexList($productIds);

if (!empty($productIds)) {
$this->_ruleProductProcessor->reindexList($productIds);
}
}

/**
Expand Down
35 changes: 32 additions & 3 deletions app/code/Magento/CatalogRule/Test/Unit/Model/RuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,9 +380,38 @@ public function testGetConditionsFieldSetId()
$this->assertEquals($expectedResult, $this->rule->getConditionsFieldSetId($formName));
}

public function testReindex()
{
$this->_ruleProductProcessor->expects($this->once())->method('reindexList');
/**
* @dataProvider reindexDataProvider
* @param array $productIds
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $callCount
* @return void
*/
public function testReindex(
array $productIds,
\PHPUnit_Framework_MockObject_Matcher_InvokedCount $callCount
) {
$this->objectManager->setBackwardCompatibleProperty($this->rule, '_productIds', $productIds);
$this->_ruleProductProcessor->expects($callCount)->method('reindexList');
$this->rule->reindex();
}

/**
* @return array
*/
public function reindexDataProvider():array
{
return [
[
'productIds' => [
1 => [1 =>true],
2 => [1 =>true],
],
'call' => $this->once(),
],
[
'productIds' => [],
'call' => $this->never(),
],
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ class Multishipping extends \Magento\Framework\DataObject
*/
private $logger;

/**
* @var \Magento\Framework\Api\DataObjectHelper
*/
private $dataObjectHelper;

/**
* Constructor
*
Expand Down Expand Up @@ -227,7 +232,8 @@ public function __construct(
\Magento\Quote\Api\Data\CartExtensionFactory $cartExtensionFactory = null,
AllowedCountries $allowedCountryReader = null,
Multishipping\PlaceOrderFactory $placeOrderFactory = null,
LoggerInterface $logger = null
LoggerInterface $logger = null,
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper = null
) {
$this->_eventManager = $eventManager;
$this->_scopeConfig = $scopeConfig;
Expand Down Expand Up @@ -258,6 +264,8 @@ public function __construct(
->get(Multishipping\PlaceOrderFactory::class);
$this->logger = $logger ?: ObjectManager::getInstance()
->get(LoggerInterface::class);
$this->dataObjectHelper = $dataObjectHelper ?: ObjectManager::getInstance()
->get(\Magento\Framework\Api\DataObjectHelper::class);
parent::__construct($data);
$this->_init();
}
Expand Down Expand Up @@ -663,7 +671,14 @@ protected function _prepareOrder(\Magento\Quote\Model\Quote\Address $address)
$quote->reserveOrderId();
$quote->collectTotals();

$order = $this->quoteAddressToOrder->convert($address);
$order = $this->_orderFactory->create();

$this->dataObjectHelper->mergeDataObjects(
\Magento\Sales\Api\Data\OrderInterface::class,
$order,
$this->quoteAddressToOrder->convert($address)
);

$order->setQuote($quote);
$order->setBillingAddress($this->quoteAddressToOrderAddress->convert($quote->getBillingAddress()));

Expand Down
Loading

0 comments on commit 8fc8439

Please sign in to comment.