Skip to content

Commit 263d075

Browse files
committed
MAGETWO-61274: Admin user with access only to Catalog cannot create configurable product
1 parent f1033b2 commit 263d075

File tree

4 files changed

+31
-27
lines changed

4 files changed

+31
-27
lines changed

app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/SelectAttributes.php

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SelectAttributes extends \Magento\Ui\Block\Component\StepsWizard\StepAbstr
1717
*
1818
* @var \Magento\Framework\Registry
1919
*/
20-
protected $coreRegistry = null;
20+
protected $registry = null;
2121

2222
/**
2323
* @param \Magento\Framework\View\Element\Template\Context $context
@@ -43,31 +43,35 @@ public function getAddNewAttributeButton($dataProvider = '')
4343
$attributeCreate = $this->getLayout()->createBlock(
4444
\Magento\Backend\Block\Widget\Button::class
4545
);
46-
$attributeCreate->setDataAttribute(
47-
[
48-
'mage-init' => [
49-
'productAttributes' => [
50-
'dataProvider' => $dataProvider,
51-
'url' => $this->getUrl('catalog/product_attribute/new', [
52-
'store' => $this->registry->registry('current_product')->getStoreId(),
53-
'product_tab' => 'variations',
54-
'popup' => 1,
55-
'_query' => [
56-
'attribute' => [
57-
'is_global' => 1,
58-
'frontend_input' => 'select',
46+
if ($attributeCreate->getAuthorization()->isAllowed('Magento_Catalog::attributes_attributes')) {
47+
$attributeCreate->setDataAttribute(
48+
[
49+
'mage-init' => [
50+
'productAttributes' => [
51+
'dataProvider' => $dataProvider,
52+
'url' => $this->getUrl('catalog/product_attribute/new', [
53+
'store' => $this->registry->registry('current_product')->getStoreId(),
54+
'product_tab' => 'variations',
55+
'popup' => 1,
56+
'_query' => [
57+
'attribute' => [
58+
'is_global' => 1,
59+
'frontend_input' => 'select',
60+
],
5961
],
60-
],
61-
]),
62+
]),
63+
],
6264
],
63-
],
64-
]
65-
)->setType(
66-
'button'
67-
)->setLabel(
68-
__('Create New Attribute')
69-
);
70-
return $attributeCreate->toHtml();
65+
]
66+
)->setType(
67+
'button'
68+
)->setLabel(
69+
__('Create New Attribute')
70+
);
71+
return $attributeCreate->toHtml();
72+
} else {
73+
return '';
74+
}
7175
}
7276

7377
/**

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CreateOptions extends Action
1616
*
1717
* @see _isAllowed()
1818
*/
19-
const ADMIN_RESOURCE = 'Magento_Catalog::attributes_attributes';
19+
const ADMIN_RESOURCE = 'Magento_Catalog::products';
2020

2121
/**
2222
* @var \Magento\Framework\Json\Helper\Data

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/GetAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class GetAttributes extends Action
1616
*
1717
* @see _isAllowed()
1818
*/
19-
const ADMIN_RESOURCE = 'Magento_Catalog::attributes_attributes';
19+
const ADMIN_RESOURCE = 'Magento_Catalog::products';
2020

2121
/**
2222
* Store manager

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class SuggestConfigurableAttributes extends Action
1616
*
1717
* @see _isAllowed()
1818
*/
19-
const ADMIN_RESOURCE = 'Magento_Catalog::attributes_attributes';
19+
const ADMIN_RESOURCE = 'Magento_Catalog::products';
2020

2121
/**
2222
* @var \Magento\ConfigurableProduct\Model\SuggestedAttributeList

0 commit comments

Comments
 (0)