/** * @return array */ public function toOptionArray() { $arr = []; foreach ($this->_carrierMatrixrate->getCode('condition_name') as $k => $v) { $arr[] = ['value' => $k, 'label' => $v]; } return $arr; }
public function testToOptionArray() { $codes = [1, 2, 3, 4, 5]; $expected = []; foreach ($codes as $k => $v) { $expected[] = ['value' => $k, 'label' => $v]; } $this->carrierMatrixrateMock->expects($this->once())->method('getCode')->willReturn($codes); $this->assertEquals($expected, $this->model->toOptionArray()); }
/** * Prepare table columns * * @return \Magento\Backend\Block\Widget\Grid\Extended */ protected function _prepareColumns() { $this->addColumn('dest_country', ['header' => __('Country'), 'index' => 'dest_country', 'default' => '*']); $this->addColumn('dest_region', ['header' => __('Region/State'), 'index' => 'dest_region', 'default' => '*']); $this->addColumn('dest_city', ['header' => __('City'), 'index' => 'dest_city', 'default' => '*']); $this->addColumn('dest_zip', ['header' => __('Zip/Postal Code From'), 'index' => 'dest_zip', 'default' => '*']); $this->addColumn('dest_zip_to', ['header' => __('Zip/Postal Code To'), 'index' => 'dest_zip_to', 'default' => '*']); $label = $this->_matrixrate->getCode('condition_name_short', $this->getConditionName()); $this->addColumn('condition_from_value', ['header' => $label . __('>'), 'index' => 'condition_from_value']); $this->addColumn('condition_to_value', ['header' => $label . __('<='), 'index' => 'condition_to_value']); $this->addColumn('price', ['header' => __('Shipping Price'), 'index' => 'price']); $this->addColumn('shipping_method', ['header' => __('Shipping Method'), 'index' => 'shipping_method']); return parent::_prepareColumns(); }
/** * Return import condition full name by condition name code * * @param string $conditionName * @return string */ protected function _getConditionFullName($conditionName) { if (!isset($this->_conditionFullNames[$conditionName])) { $name = $this->_carrierMatrixrate->getCode('condition_name_short', $conditionName); $this->_conditionFullNames[$conditionName] = $name; } return $this->_conditionFullNames[$conditionName]; }