Skip to content

Commit 9d6ae15

Browse files
Merge branch 'MAGETWO-93962' into 2.3-develop-pr5
2 parents b920465 + f4af186 commit 9d6ae15

File tree

6 files changed

+187
-72
lines changed

6 files changed

+187
-72
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\GiftMessage\Model\Plugin;
9+
10+
use Magento\Quote\Model\Quote\Item;
11+
use Magento\Quote\Model\Quote\Item\Processor;
12+
13+
class MergeQuoteItems
14+
{
15+
/**
16+
* Resolves gift message to be
17+
* applied to merged quote items.
18+
*
19+
* @param Processor $subject
20+
* @param Item $result
21+
* @param Item $source
22+
* @return Item
23+
*
24+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
25+
*/
26+
public function afterMerge(Processor $subject, Item $result, Item $source): Item
27+
{
28+
$giftMessageId = $source->getGiftMessageId();
29+
30+
if ($giftMessageId) {
31+
$result->setGiftMessageId($giftMessageId);
32+
}
33+
34+
return $result;
35+
}
36+
}

app/code/Magento/GiftMessage/Observer/SalesEventQuoteMerge.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ public function execute(\Magento\Framework\Event\Observer $observer)
2828
/** @var Quote $sourceQuote */
2929
$sourceQuote = $observer->getData('source');
3030

31-
$targetQuote->setGiftMessageId($sourceQuote->getGiftMessageId());
31+
$giftMessageId = $sourceQuote->getGiftMessageId();
32+
if ($giftMessageId) {
33+
$targetQuote->setGiftMessageId($giftMessageId);
34+
}
3235

3336
return $this;
3437
}

app/code/Magento/GiftMessage/etc/frontend/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@
4343
</argument>
4444
</arguments>
4545
</type>
46+
<type name="Magento\Quote\Model\Quote\Item\Processor">
47+
<plugin name="mergeQuoteItems" type="Magento\GiftMessage\Model\Plugin\MergeQuoteItems"/>
48+
</type>
4649
</config>

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

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -526,207 +526,207 @@ public function getCurrency()
526526
}
527527

528528
/**
529-
* {@inheritdoc}
529+
* @inheritdoc
530530
*/
531531
public function setCurrency(\Magento\Quote\Api\Data\CurrencyInterface $currency = null)
532532
{
533533
return $this->setData(self::KEY_CURRENCY, $currency);
534534
}
535535

536536
/**
537-
* {@inheritdoc}
537+
* @inheritdoc
538538
*/
539539
public function getItems()
540540
{
541541
return $this->_getData(self::KEY_ITEMS);
542542
}
543543

544544
/**
545-
* {@inheritdoc}
545+
* @inheritdoc
546546
*/
547547
public function setItems(array $items = null)
548548
{
549549
return $this->setData(self::KEY_ITEMS, $items);
550550
}
551551

552552
/**
553-
* {@inheritdoc}
553+
* @inheritdoc
554554
*/
555555
public function getCreatedAt()
556556
{
557557
return $this->_getData(self::KEY_CREATED_AT);
558558
}
559559

560560
/**
561-
* {@inheritdoc}
561+
* @inheritdoc
562562
*/
563563
public function setCreatedAt($createdAt)
564564
{
565565
return $this->setData(self::KEY_CREATED_AT, $createdAt);
566566
}
567567

568568
/**
569-
* {@inheritdoc}
569+
* @inheritdoc
570570
*/
571571
public function getUpdatedAt()
572572
{
573573
return $this->_getData(self::KEY_UPDATED_AT);
574574
}
575575

576576
/**
577-
* {@inheritdoc}
577+
* @inheritdoc
578578
*/
579579
public function setUpdatedAt($updatedAt)
580580
{
581581
return $this->setData(self::KEY_UPDATED_AT, $updatedAt);
582582
}
583583

584584
/**
585-
* {@inheritdoc}
585+
* @inheritdoc
586586
*/
587587
public function getConvertedAt()
588588
{
589589
return $this->_getData(self::KEY_CONVERTED_AT);
590590
}
591591

592592
/**
593-
* {@inheritdoc}
593+
* @inheritdoc
594594
*/
595595
public function setConvertedAt($convertedAt)
596596
{
597597
return $this->setData(self::KEY_CONVERTED_AT, $convertedAt);
598598
}
599599

600600
/**
601-
* {@inheritdoc}
601+
* @inheritdoc
602602
*/
603603
public function getIsActive()
604604
{
605605
return $this->_getData(self::KEY_IS_ACTIVE);
606606
}
607607

608608
/**
609-
* {@inheritdoc}
609+
* @inheritdoc
610610
*/
611611
public function setIsActive($isActive)
612612
{
613613
return $this->setData(self::KEY_IS_ACTIVE, $isActive);
614614
}
615615

616616
/**
617-
* {@inheritdoc}
617+
* @inheritdoc
618618
*/
619619
public function setIsVirtual($isVirtual)
620620
{
621621
return $this->setData(self::KEY_IS_VIRTUAL, $isVirtual);
622622
}
623623

624624
/**
625-
* {@inheritdoc}
625+
* @inheritdoc
626626
*/
627627
public function getItemsCount()
628628
{
629629
return $this->_getData(self::KEY_ITEMS_COUNT);
630630
}
631631

632632
/**
633-
* {@inheritdoc}
633+
* @inheritdoc
634634
*/
635635
public function setItemsCount($itemsCount)
636636
{
637637
return $this->setData(self::KEY_ITEMS_COUNT, $itemsCount);
638638
}
639639

640640
/**
641-
* {@inheritdoc}
641+
* @inheritdoc
642642
*/
643643
public function getItemsQty()
644644
{
645645
return $this->_getData(self::KEY_ITEMS_QTY);
646646
}
647647

648648
/**
649-
* {@inheritdoc}
649+
* @inheritdoc
650650
*/
651651
public function setItemsQty($itemsQty)
652652
{
653653
return $this->setData(self::KEY_ITEMS_QTY, $itemsQty);
654654
}
655655

656656
/**
657-
* {@inheritdoc}
657+
* @inheritdoc
658658
*/
659659
public function getOrigOrderId()
660660
{
661661
return $this->_getData(self::KEY_ORIG_ORDER_ID);
662662
}
663663

664664
/**
665-
* {@inheritdoc}
665+
* @inheritdoc
666666
*/
667667
public function setOrigOrderId($origOrderId)
668668
{
669669
return $this->setData(self::KEY_ORIG_ORDER_ID, $origOrderId);
670670
}
671671

672672
/**
673-
* {@inheritdoc}
673+
* @inheritdoc
674674
*/
675675
public function getReservedOrderId()
676676
{
677677
return $this->_getData(self::KEY_RESERVED_ORDER_ID);
678678
}
679679

680680
/**
681-
* {@inheritdoc}
681+
* @inheritdoc
682682
*/
683683
public function setReservedOrderId($reservedOrderId)
684684
{
685685
return $this->setData(self::KEY_RESERVED_ORDER_ID, $reservedOrderId);
686686
}
687687

688688
/**
689-
* {@inheritdoc}
689+
* @inheritdoc
690690
*/
691691
public function getCustomerIsGuest()
692692
{
693693
return $this->_getData(self::KEY_CUSTOMER_IS_GUEST);
694694
}
695695

696696
/**
697-
* {@inheritdoc}
697+
* @inheritdoc
698698
*/
699699
public function setCustomerIsGuest($customerIsGuest)
700700
{
701701
return $this->setData(self::KEY_CUSTOMER_IS_GUEST, $customerIsGuest);
702702
}
703703

704704
/**
705-
* {@inheritdoc}
705+
* @inheritdoc
706706
*/
707707
public function getCustomerNote()
708708
{
709709
return $this->_getData(self::KEY_CUSTOMER_NOTE);
710710
}
711711

712712
/**
713-
* {@inheritdoc}
713+
* @inheritdoc
714714
*/
715715
public function setCustomerNote($customerNote)
716716
{
717717
return $this->setData(self::KEY_CUSTOMER_NOTE, $customerNote);
718718
}
719719

720720
/**
721-
* {@inheritdoc}
721+
* @inheritdoc
722722
*/
723723
public function getCustomerNoteNotify()
724724
{
725725
return $this->_getData(self::KEY_CUSTOMER_NOTE_NOTIFY);
726726
}
727727

728728
/**
729-
* {@inheritdoc}
729+
* @inheritdoc
730730
*/
731731
public function setCustomerNoteNotify($customerNoteNotify)
732732
{
@@ -736,7 +736,7 @@ public function setCustomerNoteNotify($customerNoteNotify)
736736
//@codeCoverageIgnoreEnd
737737

738738
/**
739-
* {@inheritdoc}
739+
* @inheritdoc
740740
*/
741741
public function getStoreId()
742742
{
@@ -747,7 +747,7 @@ public function getStoreId()
747747
}
748748

749749
/**
750-
* {@inheritdoc}
750+
* @inheritdoc
751751
*/
752752
public function setStoreId($storeId)
753753
{
@@ -1078,7 +1078,7 @@ public function getCustomerGroupId()
10781078
}
10791079

10801080
/**
1081-
* {@inheritdoc}
1081+
* @inheritdoc
10821082
*/
10831083
public function getCustomerTaxClassId()
10841084
{
@@ -1097,7 +1097,7 @@ public function getCustomerTaxClassId()
10971097
}
10981098

10991099
/**
1100-
* {@inheritdoc}
1100+
* @inheritdoc
11011101
*/
11021102
public function setCustomerTaxClassId($customerTaxClassId)
11031103
{
@@ -2341,6 +2341,7 @@ public function merge(Quote $quote)
23412341
foreach ($this->getAllItems() as $quoteItem) {
23422342
if ($quoteItem->compare($item)) {
23432343
$quoteItem->setQty($quoteItem->getQty() + $item->getQty());
2344+
$this->itemProcessor->merge($item, $quoteItem);
23442345
$found = true;
23452346
break;
23462347
}

0 commit comments

Comments
 (0)