From ec65c015f3d9f8d617c54be8a63d9d1ecd644144 Mon Sep 17 00:00:00 2001
From: Michail Slabko <mslabko@ebay.com>
Date: Tue, 20 Oct 2015 14:36:58 +0300
Subject: [PATCH] MAGETWO-44114: Can't edit "Scope" in Product Attribute

---
 .../Adminhtml/Product/Attribute/Edit/Tab/Advanced.php  | 10 +++++++++-
 .../Product/Attribute/Edit/Tab/AdvancedTest.php        |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php
index dec89ab52ff..5ed9016a59f 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php
@@ -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);
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php
index a54834d4f56..7408df0ede1 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php
@@ -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');
-- 
GitLab