Skip to content

Commit 3d0ee6c

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-57060' into 2.1.8-develop-pr8
2 parents 9ba3060 + 9b2a49d commit 3d0ee6c

File tree

7 files changed

+158
-70
lines changed

7 files changed

+158
-70
lines changed

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ public function initFromOrderItem(\Magento\Sales\Model\Order\Item $orderItem, $q
608608
}
609609

610610
$product = $this->_objectManager->create(
611-
'Magento\Catalog\Model\Product'
611+
\Magento\Catalog\Model\Product::class
612612
)->setStoreId(
613613
$this->getSession()->getStoreId()
614614
)->load(
@@ -662,7 +662,7 @@ public function getCustomerWishlist($cacheReload = false)
662662

663663
$customerId = (int)$this->getSession()->getCustomerId();
664664
if ($customerId) {
665-
$this->_wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist');
665+
$this->_wishlist = $this->_objectManager->create(\Magento\Wishlist\Model\Wishlist::class);
666666
$this->_wishlist->loadByCustomerId($customerId, true);
667667
$this->_wishlist->setStore(
668668
$this->getSession()->getStore()
@@ -716,7 +716,9 @@ public function getCustomerCompareList()
716716
}
717717
$customerId = (int)$this->getSession()->getCustomerId();
718718
if ($customerId) {
719-
$this->_compareList = $this->_objectManager->create('Magento\Catalog\Model\Product\Compare\ListCompare');
719+
$this->_compareList = $this->_objectManager->create(
720+
\Magento\Catalog\Model\Product\Compare\ListCompare::class
721+
);
720722
} else {
721723
$this->_compareList = false;
722724
}
@@ -762,7 +764,7 @@ public function moveQuoteItem($item, $moveTo, $qty)
762764
$info->setOptions($this->_prepareOptionsForRequest($item))->setQty($qty);
763765

764766
$product = $this->_objectManager->create(
765-
'Magento\Catalog\Model\Product'
767+
\Magento\Catalog\Model\Product::class
766768
)->setStoreId(
767769
$this->getQuote()->getStoreId()
768770
)->load(
@@ -784,7 +786,7 @@ public function moveQuoteItem($item, $moveTo, $qty)
784786
if ($cart && is_null($item->getOptionByCode('additional_options'))) {
785787
//options and info buy request
786788
$product = $this->_objectManager->create(
787-
'Magento\Catalog\Model\Product'
789+
\Magento\Catalog\Model\Product::class
788790
)->setStoreId(
789791
$this->getQuote()->getStoreId()
790792
)->load(
@@ -819,13 +821,17 @@ public function moveQuoteItem($item, $moveTo, $qty)
819821
$wishlist = null;
820822
if (!isset($moveTo[1])) {
821823
$wishlist = $this->_objectManager->create(
822-
'Magento\Wishlist\Model\Wishlist'
824+
\Magento\Wishlist\Model\Wishlist::class
823825
)->loadByCustomerId(
824826
$this->getSession()->getCustomerId(),
825827
true
826828
);
827829
} else {
828-
$wishlist = $this->_objectManager->create('Magento\Wishlist\Model\Wishlist')->load($moveTo[1]);
830+
$wishlist = $this->_objectManager->create(
831+
\Magento\Wishlist\Model\Wishlist::class
832+
)
833+
->load($moveTo[1]);
834+
829835
if (!$wishlist->getId() || $wishlist->getCustomerId() != $this->getSession()->getCustomerId()
830836
) {
831837
$wishlist = null;
@@ -885,7 +891,7 @@ public function applySidebarData($data)
885891
if (isset($data['add_order_item'])) {
886892
foreach ($data['add_order_item'] as $orderItemId => $value) {
887893
/* @var $orderItem \Magento\Sales\Model\Order\Item */
888-
$orderItem = $this->_objectManager->create('Magento\Sales\Model\Order\Item')->load($orderItemId);
894+
$orderItem = $this->_objectManager->create(\Magento\Sales\Model\Order\Item::class)->load($orderItemId);
889895
$item = $this->initFromOrderItem($orderItem);
890896
if (is_string($item)) {
891897
throw new \Magento\Framework\Exception\LocalizedException(__($item));
@@ -904,7 +910,7 @@ public function applySidebarData($data)
904910
if (isset($data['add_wishlist_item'])) {
905911
foreach ($data['add_wishlist_item'] as $itemId => $qty) {
906912
$item = $this->_objectManager->create(
907-
'Magento\Wishlist\Model\Item'
913+
\Magento\Wishlist\Model\Item::class
908914
)->loadWithOptions(
909915
$itemId,
910916
'info_buyRequest'
@@ -957,12 +963,15 @@ public function removeItem($itemId, $from)
957963
case 'wishlist':
958964
$wishlist = $this->getCustomerWishlist();
959965
if ($wishlist) {
960-
$item = $this->_objectManager->create('Magento\Wishlist\Model\Item')->load($itemId);
966+
$item = $this->_objectManager->create(\Magento\Wishlist\Model\Item::class)->load($itemId);
961967
$item->delete();
962968
}
963969
break;
964970
case 'compared':
965-
$this->_objectManager->create('Magento\Catalog\Model\Product\Compare\Item')->load($itemId)->delete();
971+
$this->_objectManager->create(
972+
\Magento\Catalog\Model\Product\Compare\Item::class
973+
)
974+
->load($itemId)->delete();
966975
break;
967976
}
968977

@@ -1003,7 +1012,7 @@ public function addProduct($product, $config = 1)
10031012
if (!$product instanceof \Magento\Catalog\Model\Product) {
10041013
$productId = $product;
10051014
$product = $this->_objectManager->create(
1006-
'Magento\Catalog\Model\Product'
1015+
\Magento\Catalog\Model\Product::class
10071016
)->setStore(
10081017
$this->getSession()->getStore()
10091018
)->setStoreId(
@@ -1103,7 +1112,7 @@ public function updateQuoteItems($items)
11031112
protected function _parseOptions(\Magento\Quote\Model\Quote\Item $item, $additionalOptions)
11041113
{
11051114
$productOptions = $this->_objectManager->get(
1106-
'Magento\Catalog\Model\Product\Option\Type\DefaultType'
1115+
\Magento\Catalog\Model\Product\Option\Type\DefaultType::class
11071116
)->setProduct(
11081117
$item->getProduct()
11091118
)->getProductOptions();
@@ -1115,11 +1124,15 @@ protected function _parseOptions(\Magento\Quote\Model\Quote\Item $item, $additio
11151124
if (strlen(trim($_additionalOption))) {
11161125
try {
11171126
if (strpos($_additionalOption, ':') === false) {
1118-
throw new \Magento\Framework\Exception\LocalizedException(__('There is an error in one of the option rows.'));
1127+
throw new \Magento\Framework\Exception\LocalizedException(
1128+
__('There is an error in one of the option rows.')
1129+
);
11191130
}
11201131
list($label, $value) = explode(':', $_additionalOption, 2);
11211132
} catch (\Exception $e) {
1122-
throw new \Magento\Framework\Exception\LocalizedException(__('There is an error in one of the option rows.'));
1133+
throw new \Magento\Framework\Exception\LocalizedException(
1134+
__('There is an error in one of the option rows.')
1135+
);
11231136
}
11241137
$label = trim($label);
11251138
$value = trim($value);
@@ -1132,7 +1145,7 @@ protected function _parseOptions(\Magento\Quote\Model\Quote\Item $item, $additio
11321145
$option = $item->getProduct()->getOptionById($optionId);
11331146

11341147
$group = $this->_objectManager->get(
1135-
'Magento\Catalog\Model\Product\Option'
1148+
\Magento\Catalog\Model\Product\Option::class
11361149
)->groupFactory(
11371150
$option->getType()
11381151
)->setOption(
@@ -1231,7 +1244,7 @@ protected function _prepareOptionsForRequest($item)
12311244
$optionValue = $item->getOptionByCode('option_' . $optionId)->getValue();
12321245

12331246
$group = $this->_objectManager->get(
1234-
'Magento\Catalog\Model\Product\Option'
1247+
\Magento\Catalog\Model\Product\Option::class
12351248
)->groupFactory(
12361249
$option->getType()
12371250
)->setOption(
@@ -1255,7 +1268,7 @@ protected function _prepareOptionsForRequest($item)
12551268
*/
12561269
protected function _parseCustomPrice($price)
12571270
{
1258-
$price = $this->_objectManager->get('Magento\Framework\Locale\FormatInterface')->getNumber($price);
1271+
$price = $this->_objectManager->get(\Magento\Framework\Locale\FormatInterface::class)->getNumber($price);
12591272
$price = $price > 0 ? $price : 0;
12601273

12611274
return $price;
@@ -1360,7 +1373,7 @@ public function setShippingAddress($address)
13601373
{
13611374
if (is_array($address)) {
13621375
$shippingAddress = $this->_objectManager->create(
1363-
'Magento\Quote\Model\Quote\Address'
1376+
\Magento\Quote\Model\Quote\Address::class
13641377
)->setData(
13651378
$address
13661379
)->setAddressType(
@@ -1428,7 +1441,7 @@ public function setBillingAddress($address)
14281441
{
14291442
if (is_array($address)) {
14301443
$billingAddress = $this->_objectManager->create(
1431-
'Magento\Quote\Model\Quote\Address'
1444+
\Magento\Quote\Model\Quote\Address::class
14321445
)->setData(
14331446
$address
14341447
)->setAddressType(
@@ -1543,6 +1556,11 @@ public function setPaymentData($data)
15431556
public function applyCoupon($code)
15441557
{
15451558
$code = trim((string)$code);
1559+
$this->getQuote()->getShippingAddress()->setCollectShippingRates(true);
1560+
1561+
if (empty($code)) {
1562+
$this->getQuote()->getShippingAddress()->setFreeShipping(null);
1563+
}
15461564
$this->getQuote()->setCouponCode($code);
15471565
$this->setRecollect(true);
15481566

@@ -1568,7 +1586,7 @@ public function setAccountData($accountData)
15681586
$this->dataObjectHelper->populateWithArray(
15691587
$customer,
15701588
$data,
1571-
'\Magento\Customer\Api\Data\CustomerInterface'
1589+
\Magento\Customer\Api\Data\CustomerInterface::class
15721590
);
15731591
$this->getQuote()->updateCustomerData($customer);
15741592
$data = [];
@@ -1690,7 +1708,7 @@ protected function _validateCustomerData(\Magento\Customer\Api\Data\CustomerInte
16901708
$this->dataObjectHelper->populateWithArray(
16911709
$customer,
16921710
$data,
1693-
'\Magento\Customer\Api\Data\CustomerInterface'
1711+
\Magento\Customer\Api\Data\CustomerInterface::class
16941712
);
16951713
return $customer;
16961714
}

0 commit comments

Comments
 (0)