Skip to content

Commit

Permalink
Merge pull request #5854 from magento-tsg-csl3/2.4-develop-pr32
Browse files Browse the repository at this point in the history
[TSG-CSL3] For 2.4 (pr32)
  • Loading branch information
zakdma committed Jul 1, 2020
2 parents ba25897 + 3a0ac16 commit 735579d
Show file tree
Hide file tree
Showing 25 changed files with 450 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;

/**
* {@inheritdoc}
* @inheritdoc
*/
class ProductLinksTypeResolver implements TypeResolverInterface
{
Expand All @@ -20,9 +20,9 @@ class ProductLinksTypeResolver implements TypeResolverInterface
private $linkTypes = ['related', 'upsell', 'crosssell'];

/**
* {@inheritdoc}
* @inheritdoc
*/
public function resolveType(array $data) : string
public function resolveType(array $data): string
{
if (isset($data['link_type'])) {
$linkType = $data['link_type'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ class BatchProductLinks implements BatchServiceContractResolverInterface
/**
* @var string[]
*/
private static $linkTypes = ['related', 'upsell', 'crosssell'];
private $linkTypes;

/**
* @param array $linkTypes
*/
public function __construct(array $linkTypes)
{
$this->linkTypes = $linkTypes;
}

/**
* @inheritDoc
Expand All @@ -44,7 +52,7 @@ public function convertToServiceArgument(ResolveRequestInterface $request)
/** @var \Magento\Catalog\Model\Product $product */
$product = $value['model'];

return new ListCriteria((string)$product->getId(), self::$linkTypes, $product);
return new ListCriteria((string)$product->getId(), $this->linkTypes, $product);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions app/code/Magento/CatalogGraphQl/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,14 @@
<preference type="\Magento\CatalogGraphQl\Model\Resolver\Product\Price\Provider" for="\Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderInterface"/>

<preference type="Magento\CatalogGraphQl\Model\Resolver\Products\Query\Search" for="Magento\CatalogGraphQl\Model\Resolver\Products\Query\ProductQueryInterface"/>

<type name="\Magento\CatalogGraphQl\Model\Resolver\Product\BatchProductLinks">
<arguments>
<argument name="linkTypes" xsi:type="array">
<item name="related" xsi:type="string">related</item>
<item name="upsell" xsi:type="string">upsell</item>
<item name="crosssell" xsi:type="string">crosssell</item>
</argument>
</arguments>
</type>
</config>
12 changes: 7 additions & 5 deletions app/code/Magento/CatalogImportExport/Model/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -1595,6 +1595,7 @@ protected function _saveProducts()
}

$rowSku = $rowData[self::COL_SKU];
$rowSkuNormalized = mb_strtolower($rowSku);

if (null === $rowSku) {
$this->getErrorAggregator()->addRowToSkip($rowNum);
Expand All @@ -1604,9 +1605,9 @@ protected function _saveProducts()
$storeId = !empty($rowData[self::COL_STORE])
? $this->getStoreIdByCode($rowData[self::COL_STORE])
: Store::DEFAULT_STORE_ID;
$rowExistingImages = $existingImages[$storeId][$rowSku] ?? [];
$rowExistingImages = $existingImages[$storeId][$rowSkuNormalized] ?? [];
$rowStoreMediaGalleryValues = $rowExistingImages;
$rowExistingImages += $existingImages[Store::DEFAULT_STORE_ID][$rowSku] ?? [];
$rowExistingImages += $existingImages[Store::DEFAULT_STORE_ID][$rowSkuNormalized] ?? [];

if (self::SCOPE_STORE == $rowScope) {
// set necessary data from SCOPE_DEFAULT row
Expand Down Expand Up @@ -1762,10 +1763,11 @@ protected function _saveProducts()
continue;
}

if (isset($rowExistingImages[$uploadedFile])) {
$currentFileData = $rowExistingImages[$uploadedFile];
$uploadedFileNormalized = ltrim($uploadedFile, '/\\');
if (isset($rowExistingImages[$uploadedFileNormalized])) {
$currentFileData = $rowExistingImages[$uploadedFileNormalized];
$currentFileData['store_id'] = $storeId;
$storeMediaGalleryValueExists = isset($rowStoreMediaGalleryValues[$uploadedFile]);
$storeMediaGalleryValueExists = isset($rowStoreMediaGalleryValues[$uploadedFileNormalized]);
if (array_key_exists($uploadedFile, $imageHiddenStates)
&& $currentFileData['disabled'] != $imageHiddenStates[$uploadedFile]
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ public function getExistingImages(array $bunch)
foreach ($this->connection->fetchAll($select) as $image) {
$storeId = $image['store_id'];
unset($image['store_id']);
$result[$storeId][$image['sku']][$image['value']] = $image;
$sku = mb_strtolower($image['sku']);
$value = ltrim($image['value'], '/\\');
$result[$storeId][$sku][$value] = $image;
}

return $result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Converter implements ConverterInterface
*/
private const ES_DATA_TYPE_TEXT = 'text';
private const ES_DATA_TYPE_KEYWORD = 'keyword';
private const ES_DATA_TYPE_FLOAT = 'float';
private const ES_DATA_TYPE_DOUBLE = 'double';
private const ES_DATA_TYPE_INT = 'integer';
private const ES_DATA_TYPE_DATE = 'date';
/**#@-*/
Expand All @@ -32,7 +32,7 @@ class Converter implements ConverterInterface
private $mapping = [
self::INTERNAL_DATA_TYPE_STRING => self::ES_DATA_TYPE_TEXT,
self::INTERNAL_DATA_TYPE_KEYWORD => self::ES_DATA_TYPE_KEYWORD,
self::INTERNAL_DATA_TYPE_FLOAT => self::ES_DATA_TYPE_FLOAT,
self::INTERNAL_DATA_TYPE_FLOAT => self::ES_DATA_TYPE_DOUBLE,
self::INTERNAL_DATA_TYPE_INT => self::ES_DATA_TYPE_INT,
self::INTERNAL_DATA_TYPE_DATE => self::ES_DATA_TYPE_DATE,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function addFieldsMapping(array $fields, $index, $entityType)
'match' => 'price_*',
'match_mapping_type' => 'string',
'mapping' => [
'type' => 'float',
'type' => 'double',
'store' => true,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Converter implements ConverterInterface
* Text flags for Elasticsearch field types
*/
private const ES_DATA_TYPE_STRING = 'string';
private const ES_DATA_TYPE_FLOAT = 'float';
private const ES_DATA_TYPE_DOUBLE = 'double';
private const ES_DATA_TYPE_INT = 'integer';
private const ES_DATA_TYPE_DATE = 'date';
/**#@-*/
Expand All @@ -29,7 +29,7 @@ class Converter implements ConverterInterface
private $mapping = [
self::INTERNAL_DATA_TYPE_STRING => self::ES_DATA_TYPE_STRING,
self::INTERNAL_DATA_TYPE_KEYWORD => self::ES_DATA_TYPE_STRING,
self::INTERNAL_DATA_TYPE_FLOAT => self::ES_DATA_TYPE_FLOAT,
self::INTERNAL_DATA_TYPE_FLOAT => self::ES_DATA_TYPE_DOUBLE,
self::INTERNAL_DATA_TYPE_INT => self::ES_DATA_TYPE_INT,
self::INTERNAL_DATA_TYPE_DATE => self::ES_DATA_TYPE_DATE,
];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

declare(strict_types=1);

namespace Magento\Elasticsearch\Setup\Patch\Data;

use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Indexer\IndexerRegistry;
use Magento\CatalogSearch\Model\Indexer\Fulltext as FulltextIndexer;
use Magento\Framework\Setup\Patch\PatchInterface;

/**
* Invalidate fulltext index
*/
class InvalidateIndex implements DataPatchInterface
{
/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;

/**
* @var IndexerRegistry
*/
private $indexerRegistry;

/**
* @param ModuleDataSetupInterface $moduleDataSetup
* @param IndexerRegistry $indexerRegistry
*/
public function __construct(ModuleDataSetupInterface $moduleDataSetup, IndexerRegistry $indexerRegistry)
{
$this->moduleDataSetup = $moduleDataSetup;
$this->indexerRegistry = $indexerRegistry;
}

/**
* @inheritDoc
*/
public function apply(): PatchInterface
{
$this->indexerRegistry->get(FulltextIndexer::INDEXER_ID)->invalidate();
return $this;
}

/**
* @inheritDoc
*/
public static function getDependencies(): array
{
return [];
}

/**
* @inheritDoc
*/
public function getAliases(): array
{
return [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public function testAddFieldsMapping()
'match' => 'price_*',
'match_mapping_type' => 'string',
'mapping' => [
'type' => 'float',
'type' => 'double',
'store' => true,
],
],
Expand Down Expand Up @@ -400,7 +400,7 @@ public function testAddFieldsMappingFailure()
'match' => 'price_*',
'match_mapping_type' => 'string',
'mapping' => [
'type' => 'float',
'type' => 'double',
'store' => true,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ function ($type) use ($complexType) {
if ($type === 'string') {
return 'string';
} elseif ($type === 'float') {
return 'float';
return 'double';
} elseif ($type === 'integer') {
return 'integer';
} else {
Expand Down Expand Up @@ -281,7 +281,7 @@ public function attributeProvider()
'index' => 'no_index'
],
'price_1_1' => [
'type' => 'float',
'type' => 'double',
'store' => true
]
]
Expand All @@ -300,7 +300,7 @@ public function attributeProvider()
'index' => 'no_index'
],
'price_1_1' => [
'type' => 'float',
'type' => 'double',
'store' => true
]
],
Expand All @@ -319,7 +319,7 @@ public function attributeProvider()
'index' => 'no_index'
],
'price_1_1' => [
'type' => 'float',
'type' => 'double',
'store' => true
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function convertProvider()
{
return [
['string', 'string'],
['float', 'float'],
['float', 'double'],
['integer', 'integer'],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public function addFieldsMapping(array $fields, $index, $entityType)
'match' => 'price_*',
'match_mapping_type' => 'string',
'mapping' => [
'type' => 'float',
'type' => 'double',
'store' => true,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public function testAddFieldsMapping()
'match' => 'price_*',
'match_mapping_type' => 'string',
'mapping' => [
'type' => 'float',
'type' => 'double',
'store' => true,
],
],
Expand Down Expand Up @@ -509,7 +509,7 @@ public function testAddFieldsMappingFailure()
'match' => 'price_*',
'match_mapping_type' => 'string',
'mapping' => [
'type' => 'float',
'type' => 'double',
'store' => true,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function addFieldsMapping(array $fields, string $index, string $entityTyp
'match' => 'price_*',
'match_mapping_type' => 'string',
'mapping' => [
'type' => 'float',
'type' => 'double',
'store' => true,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public function testAddFieldsMapping()
'match' => 'price_*',
'match_mapping_type' => 'string',
'mapping' => [
'type' => 'float',
'type' => 'double',
'store' => true,
],
],
Expand Down Expand Up @@ -509,7 +509,7 @@ public function testAddFieldsMappingFailure()
'match' => 'price_*',
'match_mapping_type' => 'string',
'mapping' => [
'type' => 'float',
'type' => 'double',
'store' => true,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Magento\Framework\GraphQl\Query\Resolver\TypeResolverInterface;

/**
* {@inheritdoc}
* @inheritdoc
*/
class GroupedProductLinksTypeResolver implements TypeResolverInterface
{
Expand All @@ -20,14 +20,14 @@ class GroupedProductLinksTypeResolver implements TypeResolverInterface
private $linkTypes = ['associated'];

/**
* {@inheritdoc}
* @inheritdoc
*/
public function resolveType(array $data) : string
public function resolveType(array $data): string
{
if (isset($data['link_type'])) {
$linkType = $data['link_type'];
if (in_array($linkType, $this->linkTypes)) {
return 'GroupedProductLinks';
return 'ProductLinks';
}
}
return '';
Expand Down
7 changes: 7 additions & 0 deletions app/code/Magento/GroupedProductGraphQl/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@
</argument>
</arguments>
</type>
<type name="\Magento\CatalogGraphQl\Model\Resolver\Product\BatchProductLinks">
<arguments>
<argument name="linkTypes" xsi:type="array">
<item name="associated" xsi:type="string">associated</item>
</argument>
</arguments>
</type>
</config>
13 changes: 12 additions & 1 deletion app/code/Magento/Payment/Block/Transparent/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,21 @@ public function getRedirectUrl(): string
/**
* Returns params to be redirected.
*
* Encodes invalid UTF-8 values to UTF-8 to prevent character escape error.
* Some payment methods like PayPal, send data in merchant defined language encoding
* which can be different from the system character encoding (UTF-8).
*
* @return array
*/
public function getPostParams(): array
{
return (array)$this->_request->getPostValue();
$params = [];
foreach ($this->_request->getPostValue() as $name => $value) {
if (!empty($value) && mb_detect_encoding($value, 'UTF-8', true) === false) {
$value = utf8_encode($value);
}
$params[$name] = $value;
}
return $params;
}
}
Loading

0 comments on commit 735579d

Please sign in to comment.