Skip to content

Commit d87bf86

Browse files
author
Andrii Lugovyi
committed
Merge remote-tracking branch 'goinc/MAGETWO-36828' into prepared-pull-request
2 parents 75a14ae + f70a8e6 commit d87bf86

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
/**
3+
* Plugin for \Magento\Catalog\Model\Product\Attribute\Repository
4+
*
5+
* Copyright © 2015 Magento. All rights reserved.
6+
* See COPYING.txt for license details.
7+
*/
8+
namespace Magento\Catalog\Model\Plugin;
9+
10+
use Magento\Catalog\Model\Product\Attribute\Repository;
11+
12+
class FilterCustomAttribute
13+
{
14+
/**
15+
* @var array
16+
*/
17+
private $blackList;
18+
19+
/**
20+
* @param array $blackList
21+
*/
22+
public function __construct(array $blackList = [])
23+
{
24+
$this->blackList = $blackList;
25+
}
26+
27+
/**
28+
* Delete custom attribute
29+
*
30+
* @param Repository $repository
31+
* @param array $attributes
32+
* @return \Magento\Eav\Model\AttributeRepository
33+
*
34+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
35+
*/
36+
public function afterGetCustomAttributesMetadata(Repository $repository, array $attributes)
37+
{
38+
foreach ($attributes as $key => $attribute) {
39+
if (in_array($attribute->getAttributeCode(), $this->blackList)) {
40+
unset($attributes[$key]);
41+
}
42+
}
43+
44+
return $attributes;
45+
}
46+
}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646
<type name="Magento\Customer\Model\ResourceModel\Visitor">
4747
<plugin name="catalogLog" type="Magento\Catalog\Model\Plugin\Log" />
4848
</type>
49+
<type name="Magento\Catalog\Model\Product\Attribute\Repository">
50+
<plugin name="filterCustomAttribute" type="Magento\Catalog\Model\Plugin\FilterCustomAttribute" />
51+
</type>
52+
<type name="Magento\Catalog\Model\Plugin\FilterCustomAttribute">
53+
<arguments>
54+
<argument name="blackList" xsi:type="array">
55+
<item name="quantity_and_stock_status" xsi:type="string">quantity_and_stock_status</item>
56+
</argument>
57+
</arguments>
58+
</type>
4959
<type name="Magento\Indexer\Model\Indexer\State">
5060
<plugin name="setStatusForIndexer" type="Magento\Catalog\Model\Indexer\Category\Product\Plugin\IndexerState" />
5161
</type>

0 commit comments

Comments
 (0)