Skip to content

Commit 099886a

Browse files
authored
Merge pull request #5861 from magento-tango/TANGO-PR-07-08-2020-v23
TANGO-PR-07-08-2020-v23
2 parents e3eb76e + 02077bc commit 099886a

File tree

10 files changed

+110
-192
lines changed

10 files changed

+110
-192
lines changed

app/code/Magento/Catalog/Model/Category/Attribute/Backend/Sortby.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ public function beforeSave($object)
102102
}
103103
$object->setData($attributeCode, implode(',', $data) ?: null);
104104
}
105+
if ($attributeCode == 'default_sort_by') {
106+
$data = $object->getData($attributeCode);
107+
$attributeValue = is_array($data) ? reset($data) :
108+
(!empty($data)) ? $data : null;
109+
$object->setData($attributeCode, $attributeValue);
110+
}
105111
if (!$object->hasData($attributeCode)) {
106112
$object->setData($attributeCode, null);
107113
}

app/code/Magento/Catalog/Model/Plugin/DefaultSortByUpdateCategorySavePlugin.php

Lines changed: 0 additions & 65 deletions
This file was deleted.

app/code/Magento/Catalog/Test/Unit/Model/Plugin/DefaultSortByUpdateCategorySavePluginTest.php

Lines changed: 0 additions & 117 deletions
This file was deleted.

app/code/Magento/Catalog/etc/di.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,4 @@
13321332
</argument>
13331333
</arguments>
13341334
</type>
1335-
<type name="Magento\Catalog\Api\CategoryRepositoryInterface">
1336-
<plugin name="DefaultSortByUpdateCategorySavePlugin" type="Magento\Catalog\Model\Plugin\DefaultSortByUpdateCategorySavePlugin"/>
1337-
</type>
13381335
</config>

app/code/Magento/Paypal/Test/Mftf/Test/StorefrontPaypalSmartButtonInCheckoutPageTest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<severity value="CRITICAL"/>
1818
<testCaseId value="MC-13690"/>
1919
<group value="paypal"/>
20+
<skip>
21+
<issueId value="MC-35792"/>
22+
</skip>
2023
</annotations>
2124
<before>
2225

dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
namespace Magento\Catalog\Api;
88

99
use Magento\Authorization\Model\Role;
10+
use Magento\Authorization\Model\RoleFactory;
1011
use Magento\Authorization\Model\Rules;
12+
use Magento\Authorization\Model\RulesFactory;
13+
use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator;
1114
use Magento\Integration\Api\AdminTokenServiceInterface;
1215
use Magento\TestFramework\Helper\Bootstrap;
1316
use Magento\TestFramework\TestCase\WebapiAbstract;
1417
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
15-
use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator;
16-
use Magento\Authorization\Model\RoleFactory;
17-
use Magento\Authorization\Model\RulesFactory;
1818

1919
/**
2020
* Test repository web API.
@@ -217,6 +217,35 @@ public function testUpdate()
217217
$this->deleteCategory($categoryId);
218218
}
219219

220+
/**
221+
* @magentoApiDataFixture Magento/Catalog/_files/category.php
222+
*/
223+
public function testUpdateWithDefaultSortByAttribute()
224+
{
225+
$categoryId = 333;
226+
$categoryData = [
227+
'name' => 'Update Category Test With default_sort_by Attribute',
228+
'is_active' => true,
229+
"available_sort_by" => [],
230+
'custom_attributes' => [
231+
[
232+
'attribute_code' => 'default_sort_by',
233+
'value' => ["name"],
234+
],
235+
],
236+
];
237+
$result = $this->updateCategory($categoryId, $categoryData);
238+
$this->assertEquals($categoryId, $result['id']);
239+
/** @var \Magento\Catalog\Model\Category $model */
240+
$model = Bootstrap::getObjectManager()->get(\Magento\Catalog\Model\Category::class);
241+
$category = $model->load($categoryId);
242+
$this->assertTrue((bool)$category->getIsActive(), 'Category "is_active" must equal to true');
243+
$this->assertEquals("Update Category Test With default_sort_by Attribute", $category->getName());
244+
$this->assertEquals("name", $category->getDefaultSortBy());
245+
// delete category to clean up auto-generated url rewrites
246+
$this->deleteCategory($categoryId);
247+
}
248+
220249
protected function getSimpleCategoryData($categoryData = [])
221250
{
222251
return [

dev/tests/api-functional/testsuite/Magento/Catalog/Api/SpecialPriceStorageTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,35 @@ public function testGet()
6868
$this->assertEquals($product->getSpecialPrice(), $response[0]['price']);
6969
}
7070

71+
/**
72+
* Test get method when special price is 0.
73+
*
74+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
75+
*/
76+
public function testGetZeroValue()
77+
{
78+
$specialPrice = 0;
79+
$productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
80+
$product = $productRepository->get(self::SIMPLE_PRODUCT_SKU, true);
81+
$product->setData('special_price', $specialPrice);
82+
$productRepository->save($product);
83+
84+
$serviceInfo = [
85+
'rest' => [
86+
'resourcePath' => '/V1/products/special-price-information',
87+
'httpMethod' => Request::HTTP_METHOD_POST
88+
],
89+
'soap' => [
90+
'service' => self::SERVICE_NAME,
91+
'serviceVersion' => self::SERVICE_VERSION,
92+
'operation' => self::SERVICE_NAME . 'Get',
93+
],
94+
];
95+
$response = $this->_webApiCall($serviceInfo, ['skus' => [self::SIMPLE_PRODUCT_SKU]]);
96+
$this->assertNotEmpty($response);
97+
$this->assertEquals($specialPrice, $response[0]['price']);
98+
}
99+
71100
/**
72101
* Test update method.
73102
*

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductAttributeTypeTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testAttributeTypeResolver()
5252
attribute_type
5353
entity_type
5454
input_type
55-
}
55+
}
5656
}
5757
}
5858
QUERY;
@@ -125,7 +125,7 @@ public function testComplexAttributeTypeResolver()
125125
attribute_type
126126
entity_type
127127
input_type
128-
}
128+
}
129129
}
130130
}
131131
QUERY;
@@ -199,8 +199,8 @@ public function testUnDefinedAttributeType()
199199
{
200200
attribute_code
201201
attribute_type
202-
entity_type
203-
}
202+
entity_type
203+
}
204204
}
205205
}
206206
QUERY;

lib/internal/Magento/Framework/Locale/Format.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ class Format implements \Magento\Framework\Locale\FormatInterface
1515
*/
1616
private const JAPAN_LOCALE_CODE = 'ja_JP';
1717

18+
/**
19+
* Arab locale code
20+
*/
21+
private const ARABIC_LOCALE_CODES = [
22+
'ar_DZ',
23+
'ar_EG',
24+
'ar_KW',
25+
'ar_MA',
26+
'ar_SA',
27+
];
28+
1829
/**
1930
* @var \Magento\Framework\App\ScopeResolverInterface
2031
*/
@@ -73,6 +84,11 @@ public function getNumber($value)
7384
return (float)$value;
7485
}
7586

87+
/** Normalize for Arabic locale */
88+
if (in_array($this->_localeResolver->getLocale(), self::ARABIC_LOCALE_CODES)) {
89+
$value = $this->normalizeArabicLocale($value);
90+
}
91+
7692
//trim spaces and apostrophes
7793
$value = preg_replace('/[^0-9^\^.,-]/m', '', $value);
7894

@@ -163,4 +179,22 @@ public function getPriceFormat($localeCode = null, $currencyCode = null)
163179

164180
return $result;
165181
}
182+
183+
/**
184+
* Normalizes the number of Arabic locale.
185+
*
186+
* Substitutes Arabic thousands grouping and Arabic decimal separator symbols (U+066C, U+066B)
187+
* with common grouping and decimal separator
188+
*
189+
* @param string $value
190+
* @return string
191+
*/
192+
private function normalizeArabicLocale($value): string
193+
{
194+
$arabicGroupSymbol = '٬';
195+
$arabicDecimalSymbol = '٫';
196+
$value = str_replace([$arabicGroupSymbol, $arabicDecimalSymbol], [',', '.'], $value);
197+
198+
return $value;
199+
}
166200
}

lib/internal/Magento/Framework/Locale/Test/Unit/FormatTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ public function provideNumbers(): array
136136
['2,054.00', 2054],
137137
['4,000', 4000.0, 'ja_JP'],
138138
['4,000', 4.0, 'en_US'],
139+
['2٬599٫50', 2599.50, 'ar_EG'],
140+
['2٬000٬000٫99', 2000000.99, 'ar_SA'],
139141
];
140142
}
141143
}

0 commit comments

Comments
 (0)