+ comment="Entity ID"/>
getCountryId($rowData, $rowNumber, $columnResolver);
- $regionId = $this->getRegionId($rowData, $rowNumber, $columnResolver, $countryId);
+ $regionIds = $this->getRegionIds($rowData, $rowNumber, $columnResolver, $countryId);
$zipCode = $this->getZipCode($rowData, $columnResolver);
$conditionValue = $this->getConditionValue($rowData, $rowNumber, $conditionFullName, $columnResolver);
$price = $this->getPrice($rowData, $rowNumber, $columnResolver);
- return [
- 'website_id' => $websiteId,
- 'dest_country_id' => $countryId,
- 'dest_region_id' => $regionId,
- 'dest_zip' => $zipCode,
- 'condition_name' => $conditionShortName,
- 'condition_value' => $conditionValue,
- 'price' => $price,
- ];
+ $rates = [];
+ foreach ($regionIds as $regionId) {
+ $rates[] = [
+ 'website_id' => $websiteId,
+ 'dest_country_id' => $countryId,
+ 'dest_region_id' => $regionId,
+ 'dest_zip' => $zipCode,
+ 'condition_name' => $conditionShortName,
+ 'condition_value' => $conditionValue,
+ 'price' => $price,
+ ];
+ }
+
+ return $rates;
}
/**
+ * Get country id from provided row data.
+ *
* @param array $rowData
* @param int $rowNumber
* @param ColumnResolver $columnResolver
@@ -116,21 +130,23 @@ private function getCountryId(array $rowData, $rowNumber, ColumnResolver $column
}
/**
+ * Retrieve region id from provided row data.
+ *
* @param array $rowData
* @param int $rowNumber
* @param ColumnResolver $columnResolver
* @param int $countryId
- * @return int|string
+ * @return array
* @throws ColumnNotFoundException
* @throws RowException
*/
- private function getRegionId(array $rowData, $rowNumber, ColumnResolver $columnResolver, $countryId)
+ private function getRegionIds(array $rowData, $rowNumber, ColumnResolver $columnResolver, $countryId)
{
$regionCode = $columnResolver->getColumnValue(ColumnResolver::COLUMN_REGION, $rowData);
if ($countryId !== '0' && $this->locationDirectory->hasRegionId($countryId, $regionCode)) {
- $regionId = $this->locationDirectory->getRegionId($countryId, $regionCode);
+ $regionIds = $this->locationDirectory->getRegionIds($countryId, $regionCode);
} elseif ($regionCode === '*' || $regionCode === '') {
- $regionId = 0;
+ $regionIds = [0];
} else {
throw new RowException(
__(
@@ -141,10 +157,12 @@ private function getRegionId(array $rowData, $rowNumber, ColumnResolver $columnR
)
);
}
- return $regionId;
+ return $regionIds;
}
/**
+ * Retrieve zip code from provided row data.
+ *
* @param array $rowData
* @param ColumnResolver $columnResolver
* @return float|int|null|string
@@ -160,6 +178,8 @@ private function getZipCode(array $rowData, ColumnResolver $columnResolver)
}
/**
+ * Get condition value form provided row data.
+ *
* @param array $rowData
* @param int $rowNumber
* @param string $conditionFullName
@@ -187,6 +207,8 @@ private function getConditionValue(array $rowData, $rowNumber, $conditionFullNam
}
/**
+ * Retrieve price from provided row data.
+ *
* @param array $rowData
* @param int $rowNumber
* @param ColumnResolver $columnResolver
@@ -212,6 +234,7 @@ private function getPrice(array $rowData, $rowNumber, ColumnResolver $columnReso
/**
* Parse and validate positive decimal value
+ *
* Return false if value is not decimal or is not positive
*
* @param string $value
diff --git a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php
index a5b0d7e87d2e1..7735f8ce8999c 100644
--- a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php
+++ b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/Import.php
@@ -17,6 +17,7 @@
use Magento\Store\Model\StoreManagerInterface;
/**
+ * Import offline shipping.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Import
@@ -87,6 +88,8 @@ public function __construct(
}
/**
+ * Check if there are errors.
+ *
* @return bool
*/
public function hasErrors()
@@ -95,6 +98,8 @@ public function hasErrors()
}
/**
+ * Get errors.
+ *
* @return array
*/
public function getErrors()
@@ -103,6 +108,8 @@ public function getErrors()
}
/**
+ * Retrieve columns.
+ *
* @return array
*/
public function getColumns()
@@ -111,6 +118,8 @@ public function getColumns()
}
/**
+ * Get data from file.
+ *
* @param ReadInterface $file
* @param int $websiteId
* @param string $conditionShortName
@@ -135,7 +144,7 @@ public function getData(ReadInterface $file, $websiteId, $conditionShortName, $c
if (empty($csvLine)) {
continue;
}
- $rowData = $this->rowParser->parse(
+ $rowsData = $this->rowParser->parse(
$csvLine,
$rowNumber,
$websiteId,
@@ -144,20 +153,25 @@ public function getData(ReadInterface $file, $websiteId, $conditionShortName, $c
$columnResolver
);
- // protect from duplicate
- $hash = $this->dataHashGenerator->getHash($rowData);
- if (array_key_exists($hash, $this->uniqueHash)) {
- throw new RowException(
- __(
- 'Duplicate Row #%1 (duplicates row #%2)',
- $rowNumber,
- $this->uniqueHash[$hash]
- )
- );
+ foreach ($rowsData as $rowData) {
+ // protect from duplicate
+ $hash = $this->dataHashGenerator->getHash($rowData);
+ if (array_key_exists($hash, $this->uniqueHash)) {
+ throw new RowException(
+ __(
+ 'Duplicate Row #%1 (duplicates row #%2)',
+ $rowNumber,
+ $this->uniqueHash[$hash]
+ )
+ );
+ }
+ $this->uniqueHash[$hash] = $rowNumber;
+
+ $items[] = $rowData;
+ }
+ if (count($rowsData) > 1) {
+ $bunchSize += count($rowsData) - 1;
}
- $this->uniqueHash[$hash] = $rowNumber;
-
- $items[] = $rowData;
if (count($items) === $bunchSize) {
yield $items;
$items = [];
@@ -172,6 +186,8 @@ public function getData(ReadInterface $file, $websiteId, $conditionShortName, $c
}
/**
+ * Retrieve column headers.
+ *
* @param ReadInterface $file
* @return array|bool
* @throws LocalizedException
diff --git a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/LocationDirectory.php b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/LocationDirectory.php
index 1a311f3658a0a..e015f7b54637d 100644
--- a/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/LocationDirectory.php
+++ b/app/code/Magento/OfflineShipping/Model/ResourceModel/Carrier/Tablerate/LocationDirectory.php
@@ -6,6 +6,9 @@
namespace Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate;
+/**
+ * Location directory.
+ */
class LocationDirectory
{
/**
@@ -13,6 +16,11 @@ class LocationDirectory
*/
protected $regions;
+ /**
+ * @var array
+ */
+ private $regionsByCode;
+
/**
* @var array
*/
@@ -47,6 +55,8 @@ public function __construct(
}
/**
+ * Retrieve country id.
+ *
* @param string $countryCode
* @return null|string
*/
@@ -88,6 +98,8 @@ protected function loadCountries()
}
/**
+ * Check if there is country id with provided country code.
+ *
* @param string $countryCode
* @return bool
*/
@@ -98,6 +110,8 @@ public function hasCountryId($countryCode)
}
/**
+ * Check if there is region id with provided region code and country id.
+ *
* @param string $countryId
* @param string $regionCode
* @return bool
@@ -115,29 +129,50 @@ public function hasRegionId($countryId, $regionCode)
*/
protected function loadRegions()
{
- if ($this->regions !== null) {
+ if ($this->regions !== null && $this->regionsByCode !== null) {
return $this;
}
$this->regions = [];
+ $this->regionsByCode = [];
/** @var $collection \Magento\Directory\Model\ResourceModel\Region\Collection */
$collection = $this->_regionCollectionFactory->create();
foreach ($collection->getData() as $row) {
$this->regions[$row['country_id']][$row['code']] = (int)$row['region_id'];
+ if (empty($this->regionsByCode[$row['country_id']][$row['code']])) {
+ $this->regionsByCode[$row['country_id']][$row['code']] = [];
+ }
+ $this->regionsByCode[$row['country_id']][$row['code']][] = (int)$row['region_id'];
}
return $this;
}
/**
+ * Retrieve region id.
+ *
* @param int $countryId
* @param string $regionCode
* @return string
+ * @deprecated
*/
public function getRegionId($countryId, $regionCode)
{
$this->loadRegions();
return $this->regions[$countryId][$regionCode];
}
+
+ /**
+ * Return region ids for country and region
+ *
+ * @param int $countryId
+ * @param string $regionCode
+ * @return array
+ */
+ public function getRegionIds($countryId, $regionCode)
+ {
+ $this->loadRegions();
+ return $this->regionsByCode[$countryId][$regionCode];
+ }
}
diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/CSV/RowParserTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/CSV/RowParserTest.php
index 8c34e9a0d6510..683790c531265 100644
--- a/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/CSV/RowParserTest.php
+++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/CSV/RowParserTest.php
@@ -37,7 +37,7 @@ class RowParserTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$this->locationDirectoryMock = $this->getMockBuilder(LocationDirectory::class)
- ->setMethods(['hasCountryId', 'getCountryId', 'hasRegionId', 'getRegionId'])
+ ->setMethods(['hasCountryId', 'getCountryId', 'hasRegionId', 'getRegionIds'])
->disableOriginalConstructor()
->getMock();
$this->columnResolverMock = $this->getMockBuilder(ColumnResolver::class)
@@ -92,7 +92,7 @@ public function testParse()
$conditionShortName,
$columnValueMap
);
- $this->assertEquals($expectedResult, $result);
+ $this->assertEquals([$expectedResult], $result);
}
/**
diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php
index 4e433c380f753..722683decb4c2 100644
--- a/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php
+++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/ResourceModel/Carrier/Tablerate/ImportTest.php
@@ -77,9 +77,6 @@ protected function setUp()
->getMock();
$this->dataHashGeneratorMock = $this->getMockBuilder(DataHashGenerator::class)
->getMock();
- $this->rowParserMock->expects($this->any())
- ->method('parse')
- ->willReturnArgument(0);
$this->dataHashGeneratorMock->expects($this->any())
->method('getHash')
->willReturnCallback(
@@ -124,6 +121,15 @@ public function testGetData()
['a4', 'b4', 'c4', 'd4', 'e4'],
['a5', 'b5', 'c5', 'd5', 'e5'],
];
+ $this->rowParserMock->expects($this->any())
+ ->method('parse')
+ ->willReturn(
+ [['a1', 'b1', 'c1', 'd1', 'e1']],
+ [['a2', 'b2', 'c2', 'd2', 'e2']],
+ [['a3', 'b3', 'c3', 'd3', 'e3']],
+ [['a4', 'b4', 'c4', 'd4', 'e4']],
+ [['a5', 'b5', 'c5', 'd5', 'e5']]
+ );
$file = $this->createFileMock($lines);
$expectedResult = [
[
@@ -167,6 +173,13 @@ public function testGetDataWithDuplicatedLine()
[],
['a2', 'b2', 'c2', 'd2', 'e2'],
];
+ $this->rowParserMock->expects($this->any())
+ ->method('parse')
+ ->willReturn(
+ [['a1', 'b1', 'c1', 'd1', 'e1']],
+ [['a1', 'b1', 'c1', 'd1', 'e1']],
+ [['a2', 'b2', 'c2', 'd2', 'e2']]
+ );
$file = $this->createFileMock($lines);
$expectedResult = [
[
diff --git a/app/code/Magento/Paypal/Model/AbstractConfig.php b/app/code/Magento/Paypal/Model/AbstractConfig.php
index 3b0f7b974829c..e5beddac3b189 100644
--- a/app/code/Magento/Paypal/Model/AbstractConfig.php
+++ b/app/code/Magento/Paypal/Model/AbstractConfig.php
@@ -134,7 +134,7 @@ public function setStoreId($storeId)
* Returns payment configuration value
*
* @param string $key
- * @param null $storeId
+ * @param null|int $storeId
* @return null|string
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -224,15 +224,26 @@ protected function _prepareValue($key, $value)
*/
public function shouldUseUnilateralPayments()
{
- return $this->getValue('business_account') && !$this->isWppApiAvailabe();
+ return $this->getValue('business_account') && !$this->isWppApiAvailable();
}
/**
* Check whether WPP API credentials are available for this method
*
+ * @deprecated
* @return bool
*/
public function isWppApiAvailabe()
+ {
+ return $this->isWppApiAvailable();
+ }
+
+ /**
+ * Check whether WPP API credentials are available for this method
+ *
+ * @return bool
+ */
+ public function isWppApiAvailable()
{
return $this->getValue('api_username')
&& $this->getValue('api_password')
@@ -243,7 +254,7 @@ public function isWppApiAvailabe()
/**
* Check whether method available for checkout or not
*
- * @param null $methodCode
+ * @param null|string $methodCode
*
* @return bool
*/
diff --git a/app/code/Magento/Paypal/Model/Config.php b/app/code/Magento/Paypal/Model/Config.php
index 34e40ac7509d6..b058ba129a33f 100644
--- a/app/code/Magento/Paypal/Model/Config.php
+++ b/app/code/Magento/Paypal/Model/Config.php
@@ -10,6 +10,7 @@
/**
* Config model that is aware of all \Magento\Paypal payment methods
+ *
* Works with PayPal-specific system configuration
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
@@ -632,6 +633,7 @@ public function __construct(
/**
* Check whether method available for checkout or not
+ *
* Logic based on merchant country, methods dependence
*
* @param string|null $methodCode
@@ -677,7 +679,7 @@ public function isMethodAvailable($methodCode = null)
}
break;
case self::METHOD_BILLING_AGREEMENT:
- $result = $this->isWppApiAvailabe();
+ $result = $this->isWppApiAvailable();
break;
}
return $result;
@@ -723,6 +725,7 @@ public function getMerchantCountry()
/**
* Check whether method supported for specified country or not
+ *
* Use $_methodCode and merchant country by default
*
* @param string|null $method
@@ -896,6 +899,7 @@ public function getExpressCheckoutEditUrl($token)
/**
* Get url for additional actions that PayPal may require customer to do after placing the order.
+ *
* For instance, redirecting customer to bank for payment confirmation.
*
* @param string $token
@@ -957,6 +961,7 @@ public function areButtonsDynamic()
/**
* Express checkout shortcut pic URL getter
+ *
* PayPal will ignore "pal", if there is no total amount specified
*
* @param string $localeCode
@@ -996,6 +1001,7 @@ public function getExpressCheckoutInContextImageUrl($localeCode)
/**
* Get PayPal "mark" image URL
+ *
* Supposed to be used on payment methods selection
* $staticSize is applicable for static images only
*
@@ -1032,6 +1038,7 @@ public function getPaymentMarkImageUrl($localeCode, $orderTotal = null, $pal = n
/**
* Get "What Is PayPal" localized URL
+ *
* Supposed to be used with "mark" as popup window
*
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
@@ -1262,6 +1269,7 @@ public function getExpressCheckoutBASignupOptions()
/**
* Whether to ask customer to create billing agreements
+ *
* Unilateral payments are incompatible with the billing agreements
*
* @return bool
@@ -1376,6 +1384,7 @@ public function exportExpressCheckoutStyleSettings(\Magento\Framework\DataObject
/**
* Dynamic PayPal image URL getter
+ *
* Also can render dynamic Acceptance Mark
*
* @param string $type
@@ -1725,6 +1734,7 @@ public function getBmlPublisherId()
/**
* Get Display option from stored config
+ *
* @param string $section
*
* @return mixed
@@ -1752,6 +1762,7 @@ public function getBmlDisplay($section)
/**
* Get Position option from stored config
+ *
* @param string $section
*
* @return mixed
@@ -1767,6 +1778,7 @@ public function getBmlPosition($section)
/**
* Get Size option from stored config
+ *
* @param string $section
*
* @return mixed
diff --git a/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php b/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php
index 9ec9318212614..78bd269403b83 100644
--- a/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php
+++ b/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php
@@ -189,14 +189,14 @@ public function getValueDataProvider()
*
* @dataProvider isWppApiAvailabeDataProvider
*/
- public function testIsWppApiAvailabe($returnMap, $expectedValue)
+ public function testIsWppApiAvailable($returnMap, $expectedValue)
{
$this->config->setMethod('paypal_express');
$this->scopeConfigMock->expects($this->any())
->method('getValue')
->willReturnMap($returnMap);
- $this->assertEquals($expectedValue, $this->config->isWppApiAvailabe());
+ $this->assertEquals($expectedValue, $this->config->isWppApiAvailable());
}
/**
diff --git a/app/code/Magento/Paypal/etc/db_schema.xml b/app/code/Magento/Paypal/etc/db_schema.xml
index 2703ee4f5be30..0441231e64ac3 100644
--- a/app/code/Magento/Paypal/etc/db_schema.xml
+++ b/app/code/Magento/Paypal/etc/db_schema.xml
@@ -134,7 +134,7 @@
+ comment="Entity ID"/>
diff --git a/app/code/Magento/ProductVideo/i18n/de_DE.csv b/app/code/Magento/ProductVideo/i18n/de_DE.csv
index 7047317396999..ca24668bb8d16 100644
--- a/app/code/Magento/ProductVideo/i18n/de_DE.csv
+++ b/app/code/Magento/ProductVideo/i18n/de_DE.csv
@@ -7,3 +7,4 @@
"Preview Image","Preview Image"
"Get Video Information","Get Video Information"
"Youtube or Vimeo supported","Youtube or Vimeo supported"
+"Delete image in all store views","Delete image in all store views"
diff --git a/app/code/Magento/ProductVideo/i18n/en_US.csv b/app/code/Magento/ProductVideo/i18n/en_US.csv
index 2d226c6daefa3..debcab151cc91 100644
--- a/app/code/Magento/ProductVideo/i18n/en_US.csv
+++ b/app/code/Magento/ProductVideo/i18n/en_US.csv
@@ -40,3 +40,4 @@ Delete,Delete
"Autostart base video","Autostart base video"
"Show related video","Show related video"
"Auto restart video","Auto restart video"
+"Delete image in all store views","Delete image in all store views"
diff --git a/app/code/Magento/ProductVideo/i18n/es_ES.csv b/app/code/Magento/ProductVideo/i18n/es_ES.csv
index 7047317396999..ca24668bb8d16 100644
--- a/app/code/Magento/ProductVideo/i18n/es_ES.csv
+++ b/app/code/Magento/ProductVideo/i18n/es_ES.csv
@@ -7,3 +7,4 @@
"Preview Image","Preview Image"
"Get Video Information","Get Video Information"
"Youtube or Vimeo supported","Youtube or Vimeo supported"
+"Delete image in all store views","Delete image in all store views"
diff --git a/app/code/Magento/ProductVideo/i18n/fr_FR.csv b/app/code/Magento/ProductVideo/i18n/fr_FR.csv
index 7047317396999..ca24668bb8d16 100644
--- a/app/code/Magento/ProductVideo/i18n/fr_FR.csv
+++ b/app/code/Magento/ProductVideo/i18n/fr_FR.csv
@@ -7,3 +7,4 @@
"Preview Image","Preview Image"
"Get Video Information","Get Video Information"
"Youtube or Vimeo supported","Youtube or Vimeo supported"
+"Delete image in all store views","Delete image in all store views"
diff --git a/app/code/Magento/ProductVideo/i18n/nl_NL.csv b/app/code/Magento/ProductVideo/i18n/nl_NL.csv
index 7047317396999..5ad8386573040 100644
--- a/app/code/Magento/ProductVideo/i18n/nl_NL.csv
+++ b/app/code/Magento/ProductVideo/i18n/nl_NL.csv
@@ -7,3 +7,4 @@
"Preview Image","Preview Image"
"Get Video Information","Get Video Information"
"Youtube or Vimeo supported","Youtube or Vimeo supported"
+"Delete image in all store views","Delete image in all store views"
\ No newline at end of file
diff --git a/app/code/Magento/ProductVideo/i18n/pt_BR.csv b/app/code/Magento/ProductVideo/i18n/pt_BR.csv
index 7047317396999..5ad8386573040 100644
--- a/app/code/Magento/ProductVideo/i18n/pt_BR.csv
+++ b/app/code/Magento/ProductVideo/i18n/pt_BR.csv
@@ -7,3 +7,4 @@
"Preview Image","Preview Image"
"Get Video Information","Get Video Information"
"Youtube or Vimeo supported","Youtube or Vimeo supported"
+"Delete image in all store views","Delete image in all store views"
\ No newline at end of file
diff --git a/app/code/Magento/ProductVideo/i18n/zh_Hans_CN.csv b/app/code/Magento/ProductVideo/i18n/zh_Hans_CN.csv
index 7047317396999..5ad8386573040 100644
--- a/app/code/Magento/ProductVideo/i18n/zh_Hans_CN.csv
+++ b/app/code/Magento/ProductVideo/i18n/zh_Hans_CN.csv
@@ -7,3 +7,4 @@
"Preview Image","Preview Image"
"Get Video Information","Get Video Information"
"Youtube or Vimeo supported","Youtube or Vimeo supported"
+"Delete image in all store views","Delete image in all store views"
\ No newline at end of file
diff --git a/app/code/Magento/ProductVideo/view/adminhtml/layout/catalog_product_new.xml b/app/code/Magento/ProductVideo/view/adminhtml/layout/catalog_product_new.xml
index f5a22c50e6d0d..63bd5321ad30b 100644
--- a/app/code/Magento/ProductVideo/view/adminhtml/layout/catalog_product_new.xml
+++ b/app/code/Magento/ProductVideo/view/adminhtml/layout/catalog_product_new.xml
@@ -6,6 +6,9 @@
*/
-->
+
+
+
diff --git a/app/code/Magento/ProductVideo/view/adminhtml/templates/helper/gallery.phtml b/app/code/Magento/ProductVideo/view/adminhtml/templates/helper/gallery.phtml
index 8b0f7d8ed98df..6dff53211892f 100755
--- a/app/code/Magento/ProductVideo/view/adminhtml/templates/helper/gallery.phtml
+++ b/app/code/Magento/ProductVideo/view/adminhtml/templates/helper/gallery.phtml
@@ -140,30 +140,37 @@ $elementToggleCode = $element->getToggleCode() ? $element->getToggleCode() : 'to
alt="<%- data.label %>"/>