Skip to content

Commit

Permalink
Merge branch '2.3-develop' into 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
JackerNgo committed Mar 1, 2021
2 parents b8eaa09 + 780f86e commit c127b17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions Helper/EmailMarketing.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
use Magento\Reports\Model\ResourceModel\Order\CollectionFactory as ReportOrderCollectionFactory;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Creditmemo;
use Magento\Sales\Model\Order\Item as OrderItem;
use Magento\Sales\Model\Order\Shipment;
use Magento\Sales\Model\Order\Invoice;
use Magento\Sales\Model\ResourceModel\Order\Collection as OrderCollection;
Expand Down Expand Up @@ -720,7 +721,7 @@ public function getShipmentOrCreditmemoItems($object)
$items = [];
foreach ($object->getItems() as $item) {
$orderItem = $item->getOrderItem();
$product = $orderItem->getProduct();
$product= $this->getProductFromItem($orderItem);
if ($orderItem->getParentItemId() && isset($items[$orderItem->getParentItemId()]['bundle_items'])) {
$items[$orderItem->getParentItemId()]['bundle_items'][] = [
'title' => $item->getName(),
Expand Down Expand Up @@ -826,6 +827,16 @@ public function getItemOptions($orderItem)
return $this->formatOptions($orderItem, $result);
}

/**
* @param Item|OrderItem $item
*
* @return DataObject|Product
*/
public function getProductFromItem($item)
{
return $item->getProduct() ?: new DataObject([]);
}

/**
* @param Quote|Shipment|Creditmemo|Order $object
*
Expand All @@ -845,7 +856,7 @@ public function getCartItems($object)
/**
* @var Product $product
*/
$product = $item->getProduct();
$product = $this->getProductFromItem($item);
$productType = $item->getData('product_type');

$bundleItems = [];
Expand Down Expand Up @@ -879,7 +890,7 @@ public function getCartItems($object)
if ($item->getHasChildren()) {
$children = $isQuote ? $item->getChildren() : $item->getChildrenItems();
foreach ($children as $child) {
$product = $child->getProduct();
$product = $this->getProductFromItem($child);
if ($hasVariant) {
$itemRequest['variant_title'] = $child->getName();
$itemRequest['variant_image'] = $this->getProductImage($product);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"mageplaza/module-core": "^1.4.5"
},
"type": "magento2-module",
"version": "1.7.1",
"version": "1.7.2",
"license": "proprietary",
"authors": [
{
Expand Down

0 comments on commit c127b17

Please sign in to comment.