Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Tier.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  protected $_template = 'Magento_Catalog::catalog/product/edit/price/tier.phtml';
17 
23  protected function _getInitialCustomerGroups()
24  {
25  return [$this->_groupManagement->getAllCustomersGroup()->getId() => __('ALL GROUPS')];
26  }
27 
34  protected function _sortValues($data)
35  {
36  usort($data, [$this, '_sortTierPrices']);
37  return $data;
38  }
39 
48  protected function _sortTierPrices($a, $b)
49  {
50  if ($a['website_id'] != $b['website_id']) {
51  return $a['website_id'] < $b['website_id'] ? -1 : 1;
52  }
53  if ($a['cust_group'] != $b['cust_group']) {
54  return $this->getCustomerGroups($a['cust_group']) < $this->getCustomerGroups($b['cust_group']) ? -1 : 1;
55  }
56  if ($a['price_qty'] != $b['price_qty']) {
57  return $a['price_qty'] < $b['price_qty'] ? -1 : 1;
58  }
59 
60  return 0;
61  }
62 
69  protected function _prepareLayout()
70  {
71  $button = $this->getLayout()->createBlock(
72  \Magento\Backend\Block\Widget\Button::class
73  )->setData(
74  ['label' => __('Add Price'), 'onclick' => 'return tierPriceControl.addItem()', 'class' => 'add']
75  );
76  $button->setName('add_tier_price_item_button');
77 
78  $this->setChild('add_button', $button);
79  return parent::_prepareLayout();
80  }
81 }
__()
Definition: __.php:13