Skip to content

Commit cb53994

Browse files
committed
Merge remote-tracking branch 'magento-l3/ACP2E-36' into L3_PR_21-10-19
2 parents a79bf77 + b3e8cf7 commit cb53994

File tree

2 files changed

+81
-0
lines changed
  • app/code/Magento/Elasticsearch/etc
  • dev/tests/integration/testsuite/Magento/Elasticsearch/Catalog/Controller/Adminhtml/Product/Attribute

2 files changed

+81
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,4 +569,11 @@
569569
<argument name="cacheContext" xsi:type="object">Magento\Framework\Indexer\CacheContext\Proxy</argument>
570570
</arguments>
571571
</type>
572+
<type name="Magento\Catalog\Model\Product\ReservedAttributeList">
573+
<arguments>
574+
<argument name="reservedAttributes" xsi:type="array">
575+
<item name="category_name" xsi:type="string">category_name</item>
576+
</argument>
577+
</arguments>
578+
</type>
572579
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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\Elasticsearch\Catalog\Controller\Adminhtml\Product\Attribute;
9+
10+
use Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save\AbstractSaveAttributeTest;
11+
12+
/**
13+
* Test cases related to creating attribute and elasticsearch.
14+
*/
15+
class SaveTest extends AbstractSaveAttributeTest
16+
{
17+
/**
18+
* Default POST data for create attribute.
19+
*
20+
* @var array
21+
*/
22+
private const DEFAULT_ATTRIBUTE_POST_DATA = [
23+
'active_tab' => 'main',
24+
'frontend_label' => [
25+
'0' => 'Test attribute name',
26+
],
27+
'frontend_input' => 'select',
28+
'is_required' => '0',
29+
'attribute_code' => 'filtrable_attribute',
30+
'is_global' => '1',
31+
'default_value_yesno' => '0',
32+
'is_unique' => '0',
33+
'is_used_in_grid' => '1',
34+
'is_visible_in_grid' => '1',
35+
'is_filterable_in_grid' => '1',
36+
'is_filterable' => '1',
37+
'is_filterable_in_search' => '0',
38+
'is_searchable' => '0',
39+
'is_comparable' => '0',
40+
'is_used_for_promo_rules' => '0',
41+
'is_html_allowed_on_front' => '1',
42+
'is_visible_on_front' => '0',
43+
'used_in_product_listing' => '0',
44+
];
45+
46+
/**
47+
* @param array $data
48+
* @param string $errorMessage
49+
* @dataProvider createAttributeWithErrorDataProvider
50+
*/
51+
public function testCreateAttributeWithError(array $data, string $errorMessage): void
52+
{
53+
$this->createAttributeUsingDataWithErrorAndAssert(
54+
array_merge(self::DEFAULT_ATTRIBUTE_POST_DATA, $data),
55+
$errorMessage
56+
);
57+
}
58+
59+
/**
60+
* @return array
61+
*/
62+
public function createAttributeWithErrorDataProvider(): array
63+
{
64+
return [
65+
'should not create attribute with reserved code "category_name"' => [
66+
[
67+
'attribute_code' => 'category_name'
68+
],
69+
'The attribute code &#039;category_name&#039; is reserved by system. ' .
70+
'Please try another attribute code'
71+
]
72+
];
73+
}
74+
}

0 commit comments

Comments
 (0)