Skip to content

Commit 9f885e2

Browse files
committed
MAGETWO-66588: [Backport] Perfomance toolkit generator improvement for 2.1
1 parent eb982d5 commit 9f885e2

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Plugin\Model\Attribute\Backend;
7+
8+
use Magento\Catalog\Api\Data\ProductInterface;
9+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
10+
11+
/**
12+
* Skip validate attributes used for create configurable product
13+
*/
14+
class AttributeValidation
15+
{
16+
/**
17+
* @var Configurable
18+
*/
19+
private $configurableProductType;
20+
21+
/**
22+
* AttributeValidation constructor.
23+
* @param Configurable $configurableProductType
24+
*/
25+
public function __construct(
26+
Configurable $configurableProductType
27+
) {
28+
$this->configurableProductType = $configurableProductType;
29+
}
30+
31+
/**
32+
* @param \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend $subject
33+
* @param \Closure $proceed
34+
* @param \Magento\Framework\DataObject $entity
35+
* @return bool
36+
*/
37+
public function aroundValidate(
38+
\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend $subject,
39+
\Closure $proceed,
40+
\Magento\Framework\DataObject $entity
41+
) {
42+
$attribute = $subject->getAttribute();
43+
if ($entity instanceof ProductInterface
44+
&& $entity->getTypeId() == Configurable::TYPE_CODE
45+
&& in_array(
46+
$attribute->getAttributeId(),
47+
$this->configurableProductType->getUsedProductAttributeIds($entity),
48+
true
49+
)
50+
) {
51+
return true;
52+
}
53+
return $proceed($entity);
54+
}
55+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
<type name="Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper">
3131
<plugin name="configurable_product" type="Magento\ConfigurableProduct\Helper\Product\Configuration\SaveProductPlugin" sortOrder="50" />
3232
</type>
33+
<type name="Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend">
34+
<plugin name="ConfigurableProduct::skipValidation" type="Magento\ConfigurableProduct\Plugin\Model\Attribute\Backend\AttributeValidation"/>
35+
</type>
3336
<type name="Magento\Catalog\Model\Entity\Product\Attribute\Group\AttributeMapperInterface">
3437
<plugin name="configurable_product" type="Magento\ConfigurableProduct\Model\Entity\Product\Attribute\Group\AttributeMapper\Plugin" sortOrder="50" />
3538
</type>

0 commit comments

Comments
 (0)