Skip to content

Commit 63f34c6

Browse files
authored
Merge pull request #4525 from magento-tsg-csl3/2.3-develop-pr29
[TSG-CSL3] For 2.3 (pr29)
2 parents 2481029 + bf05216 commit 63f34c6

File tree

10 files changed

+154
-48
lines changed

10 files changed

+154
-48
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,7 @@ protected function _findNewOptionsWithTheSameTitles()
669669
*
670670
* @param array $sourceProductData
671671
* @return array
672+
* phpcs:disable Generic.Metrics.NestingLevel
672673
*/
673674
protected function _getNewOptionsWithTheSameTitlesErrorRows(array $sourceProductData)
674675
{
@@ -697,6 +698,7 @@ protected function _getNewOptionsWithTheSameTitlesErrorRows(array $sourceProduct
697698
* Find options with the same titles in DB
698699
*
699700
* @return array
701+
* phpcs:disable Generic.Metrics.NestingLevel
700702
*/
701703
protected function _findOldOptionsWithTheSameTitles()
702704
{
@@ -730,6 +732,7 @@ protected function _findOldOptionsWithTheSameTitles()
730732
* Find source file options, which have analogs in DB with the same name, but with different type
731733
*
732734
* @return array
735+
* phpcs:disable Generic.Metrics.NestingLevel
733736
*/
734737
protected function _findNewOldOptionsTypeMismatch()
735738
{
@@ -1067,7 +1070,7 @@ protected function _isSecondaryOptionRow(array $rowData)
10671070
*
10681071
* @param array &$options
10691072
* @param array &$titles
1070-
* @param array $typeValues
1073+
* @param array $typeValues
10711074
* @return bool
10721075
*/
10731076
protected function _isReadyForSaving(array &$options, array &$titles, array $typeValues)
@@ -1414,9 +1417,9 @@ protected function _initProductsSku()
14141417
/**
14151418
* Collect custom option main data to import
14161419
*
1417-
* @param array $rowData
1418-
* @param int &$prevOptionId
1419-
* @param int &$nextOptionId
1420+
* @param array $rowData
1421+
* @param int &$prevOptionId
1422+
* @param int &$nextOptionId
14201423
* @param array &$products
14211424
* @param array &$prices
14221425
* @return array|null
@@ -1454,9 +1457,9 @@ protected function _collectOptionMainData(
14541457
/**
14551458
* Collect custom option type data to import
14561459
*
1457-
* @param array $rowData
1458-
* @param int &$prevOptionId
1459-
* @param int &$nextValueId
1460+
* @param array $rowData
1461+
* @param int &$prevOptionId
1462+
* @param int &$nextValueId
14601463
* @param array &$typeValues
14611464
* @param array &$typePrices
14621465
* @param array &$typeTitles
@@ -1504,6 +1507,9 @@ protected function _collectOptionTypeData(
15041507
$specificTypeData = $this->_getSpecificTypeData($rowData, 0, false);
15051508
//For others stores
15061509
if ($specificTypeData) {
1510+
if (isset($specificTypeData['price'])) {
1511+
$typePrices[$nextValueId][$this->_rowStoreId] = $specificTypeData['price'];
1512+
}
15071513
$typeTitles[$nextValueId++][$this->_rowStoreId] = $specificTypeData['title'];
15081514
}
15091515
}
@@ -1512,8 +1518,8 @@ protected function _collectOptionTypeData(
15121518
/**
15131519
* Collect custom option title to import
15141520
*
1515-
* @param array $rowData
1516-
* @param int $prevOptionId
1521+
* @param array $rowData
1522+
* @param int $prevOptionId
15171523
* @param array &$titles
15181524
* @return void
15191525
*/
@@ -1788,29 +1794,30 @@ protected function _getPriceData(array $rowData, $optionId, $type)
17881794
*/
17891795
protected function _getSpecificTypeData(array $rowData, $optionTypeId, $defaultStore = true)
17901796
{
1797+
$data = [];
1798+
$priceData = [];
1799+
$customOptionRowPrice = $rowData[self::COLUMN_ROW_PRICE];
1800+
if (!empty($customOptionRowPrice) || $customOptionRowPrice === '0') {
1801+
$priceData['price'] = (double)rtrim($rowData[self::COLUMN_ROW_PRICE], '%');
1802+
$priceData['price_type'] = ('%' == substr($rowData[self::COLUMN_ROW_PRICE], -1)) ? 'percent' : 'fixed';
1803+
}
17911804
if (!empty($rowData[self::COLUMN_ROW_TITLE]) && $defaultStore && empty($rowData[self::COLUMN_STORE])) {
17921805
$valueData = [
17931806
'option_type_id' => $optionTypeId,
17941807
'sort_order' => empty($rowData[self::COLUMN_ROW_SORT]) ? 0 : abs($rowData[self::COLUMN_ROW_SORT]),
17951808
'sku' => !empty($rowData[self::COLUMN_ROW_SKU]) ? $rowData[self::COLUMN_ROW_SKU] : '',
17961809
];
1797-
1798-
$priceData = false;
1799-
$customOptionRowPrice = $rowData[self::COLUMN_ROW_PRICE];
1800-
if (!empty($customOptionRowPrice) || $customOptionRowPrice === '0') {
1801-
$priceData = [
1802-
'price' => (double)rtrim($rowData[self::COLUMN_ROW_PRICE], '%'),
1803-
'price_type' => 'fixed',
1804-
];
1805-
if ('%' == substr($rowData[self::COLUMN_ROW_PRICE], -1)) {
1806-
$priceData['price_type'] = 'percent';
1807-
}
1808-
}
1809-
return ['value' => $valueData, 'title' => $rowData[self::COLUMN_ROW_TITLE], 'price' => $priceData];
1810+
$data['value'] = $valueData;
1811+
$data['title'] = $rowData[self::COLUMN_ROW_TITLE];
1812+
$data['price'] = $priceData;
18101813
} elseif (!empty($rowData[self::COLUMN_ROW_TITLE]) && !$defaultStore && !empty($rowData[self::COLUMN_STORE])) {
1811-
return ['title' => $rowData[self::COLUMN_ROW_TITLE]];
1814+
if ($priceData) {
1815+
$data['price'] = $priceData;
1816+
}
1817+
$data['title'] = $rowData[self::COLUMN_ROW_TITLE];
18121818
}
1813-
return false;
1819+
1820+
return $data ?: false;
18141821
}
18151822

18161823
/**
@@ -1868,7 +1875,9 @@ protected function _saveTitles(array $titles)
18681875
{
18691876
$titleRows = [];
18701877
foreach ($titles as $optionId => $storeInfo) {
1871-
foreach ($storeInfo as $storeId => $title) {
1878+
//for use default
1879+
$uniqStoreInfo = array_unique($storeInfo);
1880+
foreach ($uniqStoreInfo as $storeId => $title) {
18721881
$titleRows[] = ['option_id' => $optionId, 'store_id' => $storeId, 'title' => $title];
18731882
}
18741883
}
@@ -1963,7 +1972,9 @@ protected function _saveSpecificTypeTitles(array $typeTitles)
19631972
{
19641973
$optionTypeTitleRows = [];
19651974
foreach ($typeTitles as $optionTypeId => $storesData) {
1966-
foreach ($storesData as $storeId => $title) {
1975+
//for use default
1976+
$uniqStoresData = array_unique($storesData);
1977+
foreach ($uniqStoresData as $storeId => $title) {
19671978
$optionTypeTitleRows[] = [
19681979
'option_type_id' => $optionTypeId,
19691980
'store_id' => $storeId,

app/code/Magento/Customer/Block/Address/Edit.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
*/
66
namespace Magento\Customer\Block\Address;
77

8-
use Magento\Framework\Exception\LocalizedException;
8+
use Magento\Customer\Api\AddressMetadataInterface;
9+
use Magento\Framework\App\ObjectManager;
910
use Magento\Framework\Exception\NoSuchEntityException;
1011

1112
/**
@@ -48,7 +49,7 @@ class Edit extends \Magento\Directory\Block\Data
4849
protected $dataObjectHelper;
4950

5051
/**
51-
* @var \Magento\Customer\Api\AddressMetadataInterface
52+
* @var AddressMetadataInterface
5253
*/
5354
private $addressMetadata;
5455

@@ -67,7 +68,7 @@ class Edit extends \Magento\Directory\Block\Data
6768
* @param \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer
6869
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
6970
* @param array $data
70-
* @param \Magento\Customer\Api\AddressMetadataInterface|null $addressMetadata
71+
* @param AddressMetadataInterface|null $addressMetadata
7172
*
7273
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
7374
*/
@@ -84,14 +85,14 @@ public function __construct(
8485
\Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer,
8586
\Magento\Framework\Api\DataObjectHelper $dataObjectHelper,
8687
array $data = [],
87-
\Magento\Customer\Api\AddressMetadataInterface $addressMetadata = null
88+
AddressMetadataInterface $addressMetadata = null
8889
) {
8990
$this->_customerSession = $customerSession;
9091
$this->_addressRepository = $addressRepository;
9192
$this->addressDataFactory = $addressDataFactory;
9293
$this->currentCustomer = $currentCustomer;
9394
$this->dataObjectHelper = $dataObjectHelper;
94-
$this->addressMetadata = $addressMetadata;
95+
$this->addressMetadata = $addressMetadata ?: ObjectManager::getInstance()->get(AddressMetadataInterface::class);
9596
parent::__construct(
9697
$context,
9798
$directoryHelper,

app/code/Magento/Customer/Model/Delegation/Storage.php

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\Customer\Model\Delegation\Data\NewOperationFactory;
2020
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
2121
use Magento\Customer\Api\Data\AddressInterfaceFactory;
22+
use Magento\Framework\Api\CustomAttributesDataInterface;
2223
use Psr\Log\LoggerInterface;
2324

2425
/**
@@ -100,11 +101,13 @@ public function storeNewOperation(CustomerInterface $customer, array $delegatedD
100101
}
101102
}
102103
$this->session->setCustomerFormData($customerData);
103-
$this->session->setDelegatedNewCustomerData([
104-
'customer' => $customerData,
105-
'addresses' => $addressesData,
106-
'delegated_data' => $delegatedData,
107-
]);
104+
$this->session->setDelegatedNewCustomerData(
105+
[
106+
'customer' => $customerData,
107+
'addresses' => $addressesData,
108+
'delegated_data' => $delegatedData,
109+
]
110+
);
108111
}
109112

110113
/**
@@ -134,18 +137,31 @@ public function consumeNewOperation()
134137
);
135138
$addressData['region'] = $region;
136139
}
137-
$addresses[] = $this->addressFactory->create(
140+
141+
$customAttributes = [];
142+
if (!empty($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES])) {
143+
$customAttributes = $addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES];
144+
unset($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES]);
145+
}
146+
147+
$address = $this->addressFactory->create(
138148
['data' => $addressData]
139149
);
150+
151+
foreach ($customAttributes as $attributeCode => $attributeValue) {
152+
$address->setCustomAttribute($attributeCode, $attributeValue);
153+
}
154+
155+
$addresses[] = $address;
140156
}
141157
$customerData = $serialized['customer'];
142158
$customerData['addresses'] = $addresses;
143159

144-
return $this->newFactory->create([
145-
'customer' => $this->customerFactory->create(
146-
['data' => $customerData]
147-
),
148-
'additionalData' => $serialized['delegated_data'],
149-
]);
160+
return $this->newFactory->create(
161+
[
162+
'customer' => $this->customerFactory->create(['data' => $customerData]),
163+
'additionalData' => $serialized['delegated_data'],
164+
]
165+
);
150166
}
151167
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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\Sales\Block\DataProviders\Email\Shipment;
9+
10+
use Magento\Framework\View\Element\Block\ArgumentInterface;
11+
use Magento\Sales\Model\Order\Shipment\Track;
12+
use Magento\Shipping\Helper\Data as ShippingHelper;
13+
14+
/**
15+
* Shipment track info for email
16+
*/
17+
class TrackingUrl implements ArgumentInterface
18+
{
19+
/**
20+
* @var ShippingHelper
21+
*/
22+
private $helper;
23+
24+
/**
25+
* @param ShippingHelper $helper
26+
*/
27+
public function __construct(ShippingHelper $helper)
28+
{
29+
$this->helper = $helper;
30+
}
31+
32+
/**
33+
* Get Shipping tracking URL
34+
*
35+
* @param Track $track
36+
* @return string
37+
*/
38+
public function getUrl(Track $track): string
39+
{
40+
return $this->helper->getTrackingPopupUrlBySalesModel($track);
41+
}
42+
}

app/code/Magento/Sales/view/frontend/layout/sales_email_order_shipment_track.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<update handle="sales_email_order_shipment_renderers"/>
1010
<body>
11-
<block class="Magento\Framework\View\Element\Template" name="sales.order.email.shipment.track" template="Magento_Sales::email/shipment/track.phtml"/>
11+
<block class="Magento\Framework\View\Element\Template" name="sales.order.email.shipment.track" template="Magento_Sales::email/shipment/track.phtml">
12+
<arguments>
13+
<argument name="tracking_url" xsi:type="object">Magento\Sales\Block\DataProviders\Email\Shipment\TrackingUrl</argument>
14+
</arguments>
15+
</block>
1216
</body>
1317
</page>

app/code/Magento/Sales/view/frontend/templates/email/shipment/track.phtml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
?>
7+
<?php /* @var \Magento\Framework\View\Element\Template $block */ ?>
88
<?php $_shipment = $block->getShipment() ?>
99
<?php
1010
/* @var \Magento\Sales\Model\Order $_order */
@@ -24,7 +24,11 @@ $_order = $block->getOrder() ?>
2424
<?php foreach ($trackCollection as $_item) : ?>
2525
<tr>
2626
<td><?= $block->escapeHtml($_item->getTitle()) ?>:</td>
27-
<td><?= $block->escapeHtml($_item->getNumber()) ?></td>
27+
<td>
28+
<a href="<?= $block->escapeUrl($block->getTrackingUrl()->getUrl($_item)) ?>" target="_blank">
29+
<?= $block->escapeHtml($_item->getNumber()) ?>
30+
</a>
31+
</td>
2832
</tr>
2933
<?php endforeach ?>
3034
</tbody>

app/code/Magento/Shipping/view/frontend/templates/tracking/popup.phtml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,13 @@ $results = $block->getTrackingInfo();
6060
</button>
6161
</div>
6262
</div>
63+
<script>
64+
require([
65+
'jquery'
66+
], function (jQuery) {
67+
/* hide the close button when the content doesn't open in a modal window */
68+
if (window.opener === null || typeof window.opener === "undefined") {
69+
jQuery('.actions button.close').hide();
70+
}
71+
});
72+
</script>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
sku,website_code,store_view_code,attribute_set_code,product_type,name,description,short_description,weight,product_online,visibility,product_websites,categories,price,special_price,special_price_from_date,special_price_to_date,tax_class_name,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,additional_images,additional_image_labels,configurable_variation_labels,configurable_variations,bundle_price_type,bundle_sku_type,bundle_weight_type,bundle_values,downloadble_samples,downloadble_links,associated_skus,related_skus,crosssell_skus,upsell_skus,custom_options,additional_attributes,manage_stock,is_in_stock,qty,out_of_stock_qty,is_qty_decimal,allow_backorders,min_cart_qty,max_cart_qty,notify_on_stock_below,qty_increments,enable_qty_increments,is_decimal_divided,new_from_date,new_to_date,gift_message_available,created_at,updated_at,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_price,msrp_display_actual_price_type,map_enabled
22
simple,base,,Default,simple,New Product,,,9,1,"Catalog, Search",base,,10,,,,Taxable Goods,new-product,,,,,,,,,,,,,,,,,,,,,,,,"name=Test Select,type=drop_down,required=1,price=3,option_title=Select Option 1,sku=3-1-select|name=Test Select,type=drop_down,required=1,price=3,option_title=Select Option 2,sku=3-2-select|name=Test Field Title,type=field,required=1,sku=1-text,price=0,price_type=fixed,max_characters=10|name=Test Date and Time Title,type=date_time,required=1,price=2,sku=2-date|name=Test Checkbox,type=checkbox,required=1,price=3,option_title=Checkbox Option 1,sku=4-1-select|name=Test Checkbox,type=checkbox,required=1,price=3,option_title=Checkbox Option 2,sku=4-2-select|name=Test Radio,type=radio,required=1,price=3,option_title=Radio Option 1,sku=5-1-radio|name=Test Radio,type=radio,required=1,price=3,option_title=Radio Option 2,sku=5-2-radio",,1,1,999,0,0,0,1,10000,1,1,0,0,,,,,,,,,,,Block after Info Column,,,
33
simple,,default,Default,simple,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"name=Test Select_default,type=drop_down,option_title=Select Option 1_default|name=Test Select_default,type=drop_down,option_title=Select Option 2_default|name=Test Field Title_default,type=field|name=Test Date and Time Title_default,type=date_time|name=Test Checkbox_default,type=checkbox,option_title=Checkbox Option 1_default|name=Test Checkbox_default,type=checkbox,option_title=Checkbox Option 2_default|name=Test Radio_default,type=radio,option_title=Radio Option 1_default|name=Test Radio_default,type=radio,option_title=Radio Option 2_default",,,,,,,,,,,,,,,,,,,,,,,,,,,
4-
simple,,fixture_second_store,Default,simple,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"name=Test Select_fixture_second_store,type=drop_down,option_title=Select Option 1_fixture_second_store|name=Test Select_fixture_second_store,type=drop_down,option_title=Select Option 2_fixture_second_store|name=Test Field Title_fixture_second_store,type=field|name=Test Date and Time Title_fixture_second_store,type=date_time|name=Test Checkbox_second_store,type=checkbox,option_title=Checkbox Option 1_second_store|name=Test Checkbox_second_store,type=checkbox,option_title=Checkbox Option 2_second_store|name=Test Radio_fixture_second_store,type=radio,option_title=Radio Option 1_fixture_second_store|name=Test Radio_fixture_second_store,type=radio,option_title=Radio Option 2_fixture_second_store",,,,,,,,,,,,,,,,,,,,,,,,,,,
4+
simple,,fixture_second_store,Default,simple,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"name=Test Select_fixture_second_store,type=drop_down,price=1,option_title=Select Option 1_fixture_second_store|name=Test Select_fixture_second_store,type=drop_down,option_title=Select Option 2_fixture_second_store|name=Test Field Title_fixture_second_store,type=field|name=Test Date and Time Title_fixture_second_store,type=date_time|name=Test Checkbox_second_store,type=checkbox,option_title=Checkbox Option 1_second_store|name=Test Checkbox_second_store,type=checkbox,option_title=Checkbox Option 2_second_store|name=Test Radio_fixture_second_store,type=radio,option_title=Radio Option 1_fixture_second_store|name=Test Radio_fixture_second_store,type=radio,option_title=Radio Option 2_fixture_second_store",,,,,,,,,,,,,,,,,,,,,,,,,,,

dev/tests/integration/testsuite/Magento/Sales/Api/OrderCustomerDelegateInterfaceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Customer\Api\Data\AddressInterface;
1212
use Magento\Customer\Api\Data\CustomerInterface;
1313
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
14+
use Magento\Framework\Api\AttributeInterface;
1415
use Magento\Sales\Api\Data\OrderAddressInterface;
1516
use Magento\Sales\Model\Order;
1617
use Magento\Sales\Model\OrderFactory;
@@ -126,6 +127,7 @@ private function compareAddresses(
126127
/**
127128
* @magentoDbIsolation enabled
128129
* @magentoAppIsolation enabled
130+
* @magentoDataFixture Magento/Customer/_files/attribute_user_defined_address.php
129131
* @magentoDataFixture Magento/Sales/_files/order.php
130132
* @return void
131133
*/

0 commit comments

Comments
 (0)