Skip to content

Commit b2fcf77

Browse files
Merge remote-tracking branch '39331/SOP-348-quote-abstract-item' into commpr-21755-2209
2 parents 216e3db + 972fea8 commit b2fcf77

File tree

1 file changed

+28
-37
lines changed

1 file changed

+28
-37
lines changed

app/code/Magento/Quote/Model/Quote/Item/AbstractItem.php

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
* Copyright 2011 Adobe
44
* All Rights Reserved.
55
*/
6+
67
namespace Magento\Quote\Model\Quote\Item;
78

8-
use Magento\Quote\Model\Quote\Item;
9+
use Magento\Catalog\Model\Product\Configuration\Item\ItemInterface;
10+
use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface;
911
use Magento\Framework\Api\AttributeValueFactory;
12+
use Magento\Framework\Model\AbstractExtensibleModel;
13+
use Magento\Quote\Model\Quote\Item;
1014

1115
/**
1216
* Quote item abstract model
@@ -25,15 +29,15 @@
2529
* @method float getBaseDiscountAmount()
2630
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseDiscountAmount(float $amount)
2731
* @method float getDiscountPercent()
28-
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountPercent()
32+
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountPercent(float $percent)
2933
* @method float getOriginalDiscountAmount()
30-
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setOriginalDiscountAmount()
34+
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setOriginalDiscountAmount(float $amount)
3135
* @method float getBaseOriginalDiscountAmount()
32-
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseOriginalDiscountAmount()
36+
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseOriginalDiscountAmount(float $amount)
3337
* @method float getDiscountCalculationPrice()
34-
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountCalculationPrice()
38+
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setDiscountCalculationPrice(float $amount)
3539
* @method float getBaseDiscountCalculationPrice()
36-
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseDiscountCalculationPrice($price)
40+
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setBaseDiscountCalculationPrice(float $price)
3741
* @method int[] getAppliedRuleIds()
3842
* @method \Magento\Quote\Model\Quote\Item\AbstractItem setAppliedRuleIds(array $ruleIds)
3943
* @method float getBaseTaxAmount()
@@ -48,8 +52,7 @@
4852
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
4953
* @since 100.0.2
5054
*/
51-
abstract class AbstractItem extends \Magento\Framework\Model\AbstractExtensibleModel implements
52-
\Magento\Catalog\Model\Product\Configuration\Item\ItemInterface
55+
abstract class AbstractItem extends AbstractExtensibleModel implements ItemInterface
5356
{
5457
/**
5558
* @var Item|null
@@ -69,7 +72,7 @@ abstract class AbstractItem extends \Magento\Framework\Model\AbstractExtensibleM
6972
/**
7073
* List of custom options
7174
*
72-
* @var array
75+
* @var OptionInterface[]
7376
*/
7477
protected $_optionsByCode;
7578

@@ -188,7 +191,7 @@ public function beforeSave()
188191
/**
189192
* Set parent item
190193
*
191-
* @param Item $parentItem
194+
* @param Item $parentItem
192195
* @return $this
193196
*/
194197
public function setParentItem($parentItem)
@@ -223,7 +226,7 @@ public function getChildren()
223226
/**
224227
* Add child item
225228
*
226-
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $child
229+
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $child
227230
* @return $this
228231
*/
229232
public function addChild($child)
@@ -236,7 +239,7 @@ public function addChild($child)
236239
/**
237240
* Adds message(s) for quote item. Duplicated messages are not added.
238241
*
239-
* @param mixed $messages
242+
* @param mixed $messages
240243
* @return $this
241244
*/
242245
public function setMessage($messages)
@@ -256,7 +259,7 @@ public function setMessage($messages)
256259
/**
257260
* Add message of quote item to array of messages
258261
*
259-
* @param mixed $message
262+
* @param string $message
260263
* @return $this
261264
*/
262265
public function addMessage($message)
@@ -268,8 +271,8 @@ public function addMessage($message)
268271
/**
269272
* Get messages array of quote item
270273
*
271-
* @param bool $string flag for converting messages to string
272-
* @return array|string
274+
* @param bool $string flag for converting messages to string
275+
* @return array|string
273276
*/
274277
public function getMessage($string = true)
275278
{
@@ -625,18 +628,12 @@ public function __clone()
625628
*/
626629
public function isChildrenCalculated()
627630
{
628-
if ($this->getParentItem()) {
629-
$calculate = $this->getParentItem()->getProduct()->getPriceType();
630-
} else {
631-
$calculate = $this->getProduct()->getPriceType();
632-
}
631+
$calculate = $this->getParentItem()
632+
? $this->getParentItem()->getProduct()->getPriceType()
633+
: $this->getProduct()->getPriceType();
633634

634-
if (null !== $calculate &&
635-
(int)$calculate === \Magento\Catalog\Model\Product\Type\AbstractType::CALCULATE_CHILD
636-
) {
637-
return true;
638-
}
639-
return false;
635+
return $calculate !== null
636+
&& (int)$calculate === \Magento\Catalog\Model\Product\Type\AbstractType::CALCULATE_CHILD;
640637
}
641638

642639
/**
@@ -649,18 +646,12 @@ public function isChildrenCalculated()
649646
*/
650647
public function isShipSeparately()
651648
{
652-
if ($this->getParentItem()) {
653-
$shipmentType = $this->getParentItem()->getProduct()->getShipmentType();
654-
} else {
655-
$shipmentType = $this->getProduct()->getShipmentType();
656-
}
649+
$shipmentType = $this->getParentItem()
650+
? $this->getParentItem()->getProduct()->getShipmentType()
651+
: $this->getProduct()->getShipmentType();
657652

658-
if (null !== $shipmentType &&
659-
(int)$shipmentType === \Magento\Catalog\Model\Product\Type\AbstractType::SHIPMENT_SEPARATELY
660-
) {
661-
return true;
662-
}
663-
return false;
653+
return null !== $shipmentType &&
654+
(int)$shipmentType === \Magento\Catalog\Model\Product\Type\AbstractType::SHIPMENT_SEPARATELY;
664655
}
665656

666657
/**

0 commit comments

Comments
 (0)