Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/2.0.11' into BUGS2.0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
slavvka committed Sep 13, 2016
2 parents 0db752b + c7a4cb4 commit 89684bb
Show file tree
Hide file tree
Showing 9 changed files with 520 additions and 81 deletions.
2 changes: 0 additions & 2 deletions app/code/Magento/Checkout/Controller/Index/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public function execute()

$this->_customerSession->regenerateId();
$this->_objectManager->get('Magento\Checkout\Model\Session')->setCartWasUpdated(false);
$currentUrl = $this->_url->getUrl('*/*/*', ['_secure' => true]);
$this->_objectManager->get('Magento\Customer\Model\Session')->setBeforeAuthUrl($currentUrl);
$this->getOnepage()->initCheckout();
$resultPage = $this->resultPageFactory->create();
$resultPage->getConfig()->getTitle()->set(__('Checkout'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ define([
}

if (!availableRate && window.checkoutConfig.selectedShippingMethod) {
availableRate = true;
availableRate = window.checkoutConfig.selectedShippingMethod;
selectShippingMethodAction(window.checkoutConfig.selectedShippingMethod);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@

class Reader extends \Magento\Framework\Config\Reader\Filesystem
{
/**
* List of id attributes for merge
*
* @var array
*/
protected $_idAttributes = ['/config/zip' => 'countryCode'];

/**
* Construct the FileSystem Reader Class
*
Expand Down
28 changes: 14 additions & 14 deletions app/code/Magento/GiftMessage/Model/Plugin/OrderGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,14 @@ public function __construct(
* Get gift message
*
* @param \Magento\Sales\Api\OrderRepositoryInterface $subject
* @param callable $proceed
* @param int $orderId
* @param \Magento\Sales\Api\Data\OrderInterface $resultOrder
* @return \Magento\Sales\Api\Data\OrderInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundGet(
public function afterGet(
\Magento\Sales\Api\OrderRepositoryInterface $subject,
\Closure $proceed,
$orderId
\Magento\Sales\Api\Data\OrderInterface $resultOrder
) {
/** @var \Magento\Sales\Api\Data\OrderInterface $resultOrder */
$resultOrder = $proceed($orderId);

$resultOrder = $this->getOrderGiftMessage($resultOrder);
$resultOrder = $this->getOrderItemGiftMessage($resultOrder);

Expand All @@ -74,7 +69,8 @@ public function aroundGet(
*/
protected function getOrderGiftMessage(\Magento\Sales\Api\Data\OrderInterface $order)
{
if ($order->getExtensionAttributes() && $order->getExtensionAttributes()->getGiftMessage()) {
$extensionAttributes = $order->getExtensionAttributes();
if ($extensionAttributes && $extensionAttributes->getGiftMessage()) {
return $order;
}

Expand All @@ -86,7 +82,7 @@ protected function getOrderGiftMessage(\Magento\Sales\Api\Data\OrderInterface $o
}

/** @var \Magento\Sales\Api\Data\OrderExtension $orderExtension */
$orderExtension = $this->orderExtensionFactory->create();
$orderExtension = $extensionAttributes ? $extensionAttributes : $this->orderExtensionFactory->create();
$orderExtension->setGiftMessage($giftMessage);
$order->setExtensionAttributes($orderExtension);

Expand All @@ -101,10 +97,12 @@ protected function getOrderGiftMessage(\Magento\Sales\Api\Data\OrderInterface $o
*/
protected function getOrderItemGiftMessage(\Magento\Sales\Api\Data\OrderInterface $order)
{
if (null !== $order->getItems()) {
$orderItems = $order->getItems();
if (null !== $orderItems) {
/** @var \Magento\Sales\Api\Data\OrderItemInterface $orderItem */
foreach ($order->getItems() as $orderItem) {
if ($orderItem->getExtensionAttributes() && $orderItem->getExtensionAttributes()->getGiftMessage()) {
foreach ($orderItems as $orderItem) {
$extensionAttributes = $orderItem->getExtensionAttributes();
if ($extensionAttributes && $extensionAttributes->getGiftMessage()) {
continue;
}

Expand All @@ -119,7 +117,9 @@ protected function getOrderItemGiftMessage(\Magento\Sales\Api\Data\OrderInterfac
}

/** @var \Magento\Sales\Api\Data\OrderItemExtension $orderItemExtension */
$orderItemExtension = $this->orderItemExtensionFactory->create();
$orderItemExtension = $extensionAttributes
? $extensionAttributes
: $this->orderItemExtensionFactory->create();
$orderItemExtension->setGiftMessage($giftMessage);
$orderItem->setExtensionAttributes($orderItemExtension);
}
Expand Down
47 changes: 24 additions & 23 deletions app/code/Magento/GiftMessage/Model/Plugin/OrderSave.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ public function __construct(
* Save gift message
*
* @param \Magento\Sales\Api\OrderRepositoryInterface $subject
* @param callable $proceed
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @param \Magento\Sales\Api\Data\OrderInterface $resultOrder
* @return \Magento\Sales\Api\Data\OrderInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @throws CouldNotSaveException
*/
public function aroundSave(
public function afterSave(
\Magento\Sales\Api\OrderRepositoryInterface $subject,
\Closure $proceed,
\Magento\Sales\Api\Data\OrderInterface $order
\Magento\Sales\Api\Data\OrderInterface $resultOrder
) {
/** @var \Magento\Sales\Api\Data\OrderInterface $resultOrder */
$resultOrder = $proceed($order);
$resultOrder = $this->saveOrderGiftMessage($resultOrder);
$resultOrder = $this->saveOrderItemGiftMessage($resultOrder);

Expand All @@ -58,24 +56,24 @@ public function aroundSave(
*
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @return \Magento\Sales\Api\Data\OrderInterface
* @throws CouldNotSaveException
*/
protected function saveOrderGiftMessage(\Magento\Sales\Api\Data\OrderInterface $order)
{
$extensionAttributes = $order->getExtensionAttributes();
if (
null !== $order->getExtensionAttributes() &&
null !== $order->getExtensionAttributes()->getGiftMessage()
null !== $extensionAttributes &&
null !== $extensionAttributes->getGiftMessage()
) {
/* @var \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage */
$giftMessage = $order->getExtensionAttributes()->getGiftMessage();
if (null !== $giftMessage) {
try {
$this->giftMessageOrderRepository->save($order->getEntityId(), $giftMessage);
} catch (\Exception $e) {
throw new CouldNotSaveException(
__('Could not add gift message to order: "%1"', $e->getMessage()),
$e
);
}
$giftMessage = $extensionAttributes->getGiftMessage();
try {
$this->giftMessageOrderRepository->save($order->getEntityId(), $giftMessage);
} catch (\Exception $e) {
throw new CouldNotSaveException(
__('Could not add gift message to order: "%1"', $e->getMessage()),
$e
);
}
}
return $order;
Expand All @@ -86,18 +84,21 @@ protected function saveOrderGiftMessage(\Magento\Sales\Api\Data\OrderInterface $
*
* @param \Magento\Sales\Api\Data\OrderInterface $order
* @return \Magento\Sales\Api\Data\OrderInterface
* @throws CouldNotSaveException
*/
protected function saveOrderItemGiftMessage(\Magento\Sales\Api\Data\OrderInterface $order)
{
if (null !== $order->getItems()) {
$items = $order->getItems();
if (null !== $items) {
/** @var \Magento\Sales\Api\Data\OrderItemInterface $orderItem */
foreach ($order->getItems() as $orderItem) {
foreach ($items as $orderItem) {
$extensionAttribute = $orderItem->getExtensionAttributes();
if (
null !== $orderItem->getExtensionAttributes() &&
null !== $orderItem->getExtensionAttributes()->getGiftMessage()
null !== $extensionAttribute &&
null !== $extensionAttribute->getGiftMessage()
) {
/* @var \Magento\GiftMessage\Api\Data\MessageInterface $giftMessage */
$giftMessage = $orderItem->getExtensionAttributes()->getGiftMessage();
$giftMessage = $extensionAttribute->getGiftMessage();
try {
$this->giftMessageOrderItemRepository->save(
$order->getEntityId(),
Expand Down
Loading

0 comments on commit 89684bb

Please sign in to comment.