Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SelectAttributes.php
Go to the documentation of this file.
1 <?php
7 
14 class SelectAttributes extends \Magento\Ui\Block\Component\StepsWizard\StepAbstract
15 {
21  protected $coreRegistry = null;
22 
27  public function __construct(
28  \Magento\Framework\View\Element\Template\Context $context,
29  \Magento\Framework\Registry $registry
30  ) {
31  parent::__construct($context);
32  $this->coreRegistry = $registry;
33  }
34 
41  public function getAddNewAttributeButton($dataProvider = '')
42  {
44  $attributeCreate = $this->getLayout()->createBlock(
45  \Magento\Backend\Block\Widget\Button::class
46  );
47  if ($attributeCreate->getAuthorization()->isAllowed('Magento_Catalog::attributes_attributes')) {
48  $attributeCreate->setDataAttribute(
49  [
50  'mage-init' => [
51  'productAttributes' => [
52  'dataProvider' => $dataProvider,
53  'url' => $this->getUrl('catalog/product_attribute/new', [
54  'store' => $this->coreRegistry->registry('current_product')->getStoreId(),
55  'product_tab' => 'variations',
56  'popup' => 1,
57  '_query' => [
58  'attribute' => [
59  'is_global' => 1,
60  'frontend_input' => 'select',
61  ],
62  ],
63  ]),
64  ],
65  ],
66  ]
67  )->setType(
68  'button'
69  )->setLabel(
70  __('Create New Attribute')
71  );
72  return $attributeCreate->toHtml();
73  } else {
74  return '';
75  }
76  }
77 
81  public function getCaption()
82  {
83  return __('Select Attributes');
84  }
85 }
__construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\Registry $registry)
__()
Definition: __.php:13