Skip to content

Commit

Permalink
ENGCOM-4377: Fixed #21425 Date design change show not correctly value…
Browse files Browse the repository at this point in the history
… in backend #21443

 - Merge Pull Request #21443 from opencommerce/magento2:2.3-developPR21425
 - Merged commits:
   1. 68ee3af
   2. 8e95bfd
   3. f0a98a5
  • Loading branch information
magento-engcom-team committed Feb 28, 2019
2 parents c66d745 + f0a98a5 commit d394192
Show file tree
Hide file tree
Showing 48 changed files with 1,963 additions and 401 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace Magento\Backend\Block\System\Design\Edit\Tab;

/**
* General system tab block.
*/
class General extends \Magento\Backend\Block\Widget\Form\Generic
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,15 @@
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveCategory"/>
<seeElement selector="{{AdminCategoryMessagesSection.SuccessMessage}}" stepKey="assertSuccessMessage"/>
</actionGroup>

<actionGroup name="AdminAssignProductToCategory">
<arguments>
<argument name="productId" type="string"/>
<argument name="categoryName" type="string"/>
</arguments>
<amOnPage url="{{AdminProductEditPage.url(productId)}}" stepKey="amOnPage"/>
<searchAndMultiSelectOption selector="{{AdminProductFormSection.categoriesDropdown}}" parameterArray="[{{categoryName}}]" stepKey="selectCategory"/>
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickOnSaveButton"/>
<see selector="{{AdminMessagesSection.success}}" userInput="You saved the product." stepKey="seeSaveProductMessage"/>
</actionGroup>
</actionGroups>
19 changes: 19 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductLinkData.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="RelatedProductLink" type="product_link">
<var key="sku" entityKey="sku" entityType="product2"/>
<var key="linked_product_sku" entityKey="sku" entityType="product"/>
<data key="link_type">related</data>
<data key="linked_product_type">simple</data>
<data key="position">1</data>
<requiredEntity type="product_link_extension_attribute">Qty1000</requiredEntity>
</entity>
</entities>
14 changes: 14 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/ProductLinksData.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="OneRelatedProductLink" type="product_links">
<requiredEntity type="product_link">RelatedProductLink</requiredEntity>
</entity>
</entities>
15 changes: 15 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Data/WidgetsData.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
<entity name="ProductLinkWidget" extends="ProductsListWidget">
<data key="type">Catalog Product Link</data>
<data key="template">Product Link Block Template</data>
</entity>
</entities>
14 changes: 14 additions & 0 deletions app/code/Magento/Catalog/Test/Mftf/Page/AdminNewWidgetPage.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
<page name="AdminNewWidgetPage" url="admin/widget_instance/new/" area="admin" module="Magento_Widget">
<section name="AdminNewWidgetSelectProductPopupSection"/>
</page>
</pages>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminNewWidgetSection">
<element name="selectProduct" type="button" selector=".btn-chooser" timeout="30"/>
</section>
</sections>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
<section name="AdminNewWidgetSelectProductPopupSection">
<element name="filterBySku" type="input" selector=".data-grid-filters input[name='chooser_sku']"/>
<element name="firstRow" type="select" selector=".even>td" timeout="20"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,17 @@
<requiredEntity createDataKey="createConfigChildProduct2"/>
</createData>
</actionGroup>

<!-- Create the configurable product, children are not visible individually -->
<actionGroup name="AdminCreateApiConfigurableProductWithHiddenChildActionGroup" extends="AdminCreateApiConfigurableProductActionGroup">
<!-- Create the 2 children that will be a part of the configurable product -->
<createData entity="ApiSimpleOneHidden" stepKey="createConfigChildProduct1">
<requiredEntity createDataKey="createConfigProductAttribute"/>
<requiredEntity createDataKey="getConfigAttributeOption1"/>
</createData>
<createData entity="ApiSimpleTwoHidden" stepKey="createConfigChildProduct2">
<requiredEntity createDataKey="createConfigProductAttribute"/>
<requiredEntity createDataKey="getConfigAttributeOption2"/>
</createData>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Fedex\Plugin\Block\DataProviders\Tracking;

use Magento\Fedex\Model\Carrier;
use Magento\Shipping\Model\Tracking\Result\Status;
use Magento\Shipping\Block\DataProviders\Tracking\DeliveryDateTitle as Subject;

/**
* Plugin to change delivery date title with FedEx customized value
*/
class ChangeTitle
{
/**
* Title modification in case if FedEx used as carrier
*
* @param Subject $subject
* @param \Magento\Framework\Phrase|string $result
* @param Status $trackingStatus
* @return \Magento\Framework\Phrase|string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetTitle(Subject $subject, $result, Status $trackingStatus)
{
if ($trackingStatus->getCarrier() === Carrier::CODE) {
$result = __('Expected Delivery:');
}
return $result;
}
}
54 changes: 54 additions & 0 deletions app/code/Magento/Fedex/Plugin/Block/Tracking/PopupDeliveryDate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Fedex\Plugin\Block\Tracking;

use Magento\Shipping\Block\Tracking\Popup;
use Magento\Fedex\Model\Carrier;
use Magento\Shipping\Model\Tracking\Result\Status;

/**
* Plugin to update delivery date value in case if Fedex used
*/
class PopupDeliveryDate
{
/**
* Show only date for expected delivery in case if Fedex is a carrier
*
* @param Popup $subject
* @param string $result
* @param string $date
* @param string $time
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterFormatDeliveryDateTime(Popup $subject, $result, $date, $time)
{
if ($this->getCarrier($subject) === Carrier::CODE) {
$result = $subject->formatDeliveryDate($date);
}
return $result;
}

/**
* Retrieve carrier name from tracking info
*
* @param Popup $subject
* @return string
*/
private function getCarrier(Popup $subject): string
{
foreach ($subject->getTrackingInfo() as $trackingData) {
foreach ($trackingData as $trackingInfo) {
if ($trackingInfo instanceof Status) {
$carrier = $trackingInfo->getCarrier();
return $carrier;
}
}
}
return '';
}
}
6 changes: 6 additions & 0 deletions app/code/Magento/Fedex/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@
</argument>
</arguments>
</type>
<type name="Magento\Shipping\Block\DataProviders\Tracking\DeliveryDateTitle">
<plugin name="update_delivery_date_title" type="Magento\Fedex\Plugin\Block\DataProviders\Tracking\ChangeTitle"/>
</type>
<type name="Magento\Shipping\Block\Tracking\Popup">
<plugin name="update_delivery_date_value" type="Magento\Fedex\Plugin\Block\Tracking\PopupDeliveryDate"/>
</type>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function execute(QuoteAddress $address): array
$addressData['model'] = $address;

$addressData = array_merge($addressData, [
'address_id' => $address->getId(),
'country' => [
'code' => $address->getCountryId(),
'label' => $address->getCountry()
Expand Down
10 changes: 5 additions & 5 deletions app/code/Magento/QuoteGraphQl/Model/Cart/GetCartForUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public function __construct(
* Get cart for user
*
* @param string $cartHash
* @param int|null $userId
* @param int|null $customerId
* @return Quote
* @throws GraphQlAuthorizationException
* @throws GraphQlNoSuchEntityException
*/
public function execute(string $cartHash, ?int $userId): Quote
public function execute(string $cartHash, ?int $customerId): Quote
{
try {
$cartId = $this->maskedQuoteIdToQuoteId->execute($cartHash);
Expand All @@ -69,14 +69,14 @@ public function execute(string $cartHash, ?int $userId): Quote
);
}

$customerId = (int)$cart->getCustomerId();
$cartCustomerId = (int)$cart->getCustomerId();

/* Guest cart, allow operations */
if (!$customerId) {
if (!$cartCustomerId && null === $customerId) {
return $cart;
}

if ($customerId !== $userId) {
if ($cartCustomerId !== $customerId) {
throw new GraphQlAuthorizationException(
__(
'The current user cannot perform operations on cart "%masked_cart_id"',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
);
}
if (null === $customerAddressId) {
$addressInput['country_id'] = $addressInput['country_code'] ?? '';
$billingAddress = $this->addressModel->addData($addressInput);
} else {
$this->checkCustomerAccount->execute($context->getUserId(), $context->getUserType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
);
}
if (null === $customerAddressId) {
$addressInput['country_id'] = $addressInput['country_code'] ?? '';
$shippingAddress = $this->addressModel->addData($addressInput);
} else {
$this->checkCustomerAccount->execute($context->getUserId(), $context->getUserType());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\QuoteGraphQl\Model\Resolver;

use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;

/**
* @inheritdoc
*/
class SelectedPaymentMethod implements ResolverInterface
{
/**
* @inheritdoc
*/
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
if (!isset($value['model'])) {
throw new LocalizedException(__('"model" value should be specified'));
}

/** @var \Magento\Quote\Model\Quote $cart */
$cart = $value['model'];

$payment = $cart->getPayment();
if (!$payment) {
return [];
}

return [
'code' => $payment->getMethod(),
'purchase_order_number' => $payment->getPoNumber(),
];
}
}
Loading

0 comments on commit d394192

Please sign in to comment.