Skip to content
Snippets Groups Projects
Commit ec65c015 authored by Michail Slabko's avatar Michail Slabko
Browse files

MAGETWO-44114: Can't edit "Scope" in Product Attribute

parent 24abff16
Branches
No related merge requests found
......@@ -31,12 +31,18 @@ class Advanced extends Generic
*/
protected $_yesNo;
/**
* @var array
*/
protected $disableScopeChangeList;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Data\FormFactory $formFactory
* @param Yesno $yesNo
* @param Data $eavData
* @param array $disableScopeChangeList
* @param array $data
*/
public function __construct(
......@@ -45,10 +51,12 @@ class Advanced extends Generic
\Magento\Framework\Data\FormFactory $formFactory,
Yesno $yesNo,
Data $eavData,
array $disableScopeChangeList = ['sku'],
array $data = []
) {
$this->_yesNo = $yesNo;
$this->_eavData = $eavData;
$this->disableScopeChangeList = $disableScopeChangeList;
parent::__construct($context, $registry, $formFactory, $data);
}
......@@ -229,7 +237,7 @@ class Advanced extends Generic
);
$this->_eventManager->dispatch('product_attribute_form_build', ['form' => $form]);
if ($attributeObject->getId() && !$attributeObject->getIsUserDefined()) {
if (in_array($attributeObject->getAttributeCode(), $this->disableScopeChangeList)) {
$form->getElement('is_global')->setDisabled(1);
}
$this->setForm($form);
......
......@@ -89,7 +89,7 @@ class AdvancedTest extends \PHPUnit_Framework_TestCase
$this->localeDate->expects($this->any())->method('getDateFormat')->willReturn('mm/dd/yy');
$entityType->expects($this->any())->method('getEntityTypeCode')->willReturn('entity_type_code');
$this->eavData->expects($this->any())->method('getFrontendClasses')->willReturn([]);
$formElement->expects($this->exactly(3))->method('setDisabled')->willReturnSelf();
$formElement->expects($this->exactly(2))->method('setDisabled')->willReturnSelf();
$this->yesNo->expects($this->any())->method('toOptionArray')->willReturn(['yes', 'no']);
$this->filesystem->expects($this->any())->method('getDirectoryRead')->willReturn($directoryReadInterface);
$directoryReadInterface->expects($this->any())->method('getRelativePath')->willReturn('relative_path');
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment