Example #1
0
 public function testGetOptionArray()
 {
     $options = $this->_productType->getOptionArray();
     $this->assertArrayHasKey(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE, $options);
     $this->assertArrayHasKey(\Magento\Catalog\Model\Product\Type::TYPE_VIRTUAL, $options);
     $this->assertArrayHasKey(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE, $options);
     $this->assertArrayHasKey(\Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE, $options);
 }
Example #2
0
 /**
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareColumns()
 {
     $this->addColumn('entity_id', ['header' => __('ID'), 'type' => 'number', 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id']);
     $this->addColumn('name', ['header' => __('Name'), 'index' => 'name', 'class' => 'xxx']);
     $store = $this->_getStore();
     if ($store->getId()) {
         $this->addColumn('custom_name', ['header' => __('Name in %1', $store->getName()), 'index' => 'custom_name', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name']);
     }
     $this->addColumn('type', ['header' => __('Type'), 'index' => 'type_id', 'type' => 'options', 'options' => $this->_type->getOptionArray()]);
     $sets = $this->_setsFactory->create()->setEntityTypeFilter($this->_productFactory->create()->getResource()->getTypeId())->load()->toOptionHash();
     $this->addColumn('set_name', ['header' => __('Product Template'), 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets, 'header_css_class' => 'col-attr-name', 'column_css_class' => 'col-attr-name']);
     $this->addColumn('sku', ['header' => __('SKU'), 'index' => 'sku']);
     $store = $this->_getStore();
     $this->addColumn('price', ['header' => __('Price'), 'type' => 'price', 'currency_code' => $store->getBaseCurrency()->getCode(), 'index' => 'price', 'header_css_class' => 'col-price', 'column_css_class' => 'col-price']);
     if ($this->moduleManager->isEnabled('Magento_CatalogInventory')) {
         $this->addColumn('qty', ['header' => __('Quantity'), 'type' => 'number', 'index' => 'qty']);
     }
     $this->addColumn('visibility', ['header' => __('Visibility'), 'index' => 'visibility', 'type' => 'options', 'options' => $this->_visibility->getOptionArray(), 'header_css_class' => 'col-visibility', 'column_css_class' => 'col-visibility']);
     $this->addColumn('status', ['header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->_status->getOptionArray()]);
     if (!$this->_storeManager->isSingleStoreMode()) {
         $this->addColumn('websites', ['header' => __('Websites'), 'sortable' => false, 'index' => 'websites', 'type' => 'options', 'options' => $this->_websiteFactory->create()->getCollection()->toOptionHash(), 'header_css_class' => 'col-websites', 'column_css_class' => 'col-websites']);
     }
     $this->addColumn('edit', ['header' => __('Edit'), 'type' => 'action', 'getter' => 'getId', 'actions' => [['caption' => __('Edit'), 'url' => ['base' => '*/*/edit', 'params' => ['store' => $this->getRequest()->getParam('store')]], 'field' => 'id']], 'filter' => false, 'sortable' => false, 'index' => 'stores', 'header_css_class' => 'col-action', 'column_css_class' => 'col-action']);
     $block = $this->getLayout()->getBlock('grid.bottom.links');
     if ($block) {
         $this->setChild('grid.bottom.links', $block);
     }
     return parent::_prepareColumns();
 }
Example #3
0
 /**
  * @return $this
  */
 protected function _prepareColumns()
 {
     $this->addColumn('entity_id', array('header' => __('ID'), 'type' => 'number', 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id'));
     $this->addColumn('name', array('header' => __('Name'), 'index' => 'name', 'class' => 'xxx'));
     $store = $this->_getStore();
     if ($store->getId()) {
         $this->addColumn('custom_name', array('header' => __('Name in %1', $store->getName()), 'index' => 'custom_name', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name'));
     }
     $this->addColumn('type', array('header' => __('Type'), 'index' => 'type_id', 'type' => 'options', 'options' => $this->_type->getOptionArray()));
     $sets = $this->_setsFactory->create()->setEntityTypeFilter($this->_productFactory->create()->getResource()->getTypeId())->load()->toOptionHash();
     $this->addColumn('set_name', array('header' => __('Attribute Set'), 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets, 'header_css_class' => 'col-attr-name', 'column_css_class' => 'col-attr-name'));
     $this->addColumn('sku', array('header' => __('SKU'), 'index' => 'sku'));
     $store = $this->_getStore();
     $this->addColumn('price', array('header' => __('Price'), 'type' => 'price', 'currency_code' => $store->getBaseCurrency()->getCode(), 'index' => 'price', 'header_css_class' => 'col-price', 'column_css_class' => 'col-price'));
     if ($this->_catalogData->isModuleEnabled('Magento_CatalogInventory')) {
         $this->addColumn('qty', array('header' => __('Quantity'), 'type' => 'number', 'index' => 'qty'));
     }
     $this->addColumn('visibility', array('header' => __('Visibility'), 'index' => 'visibility', 'type' => 'options', 'options' => $this->_visibility->getOptionArray(), 'header_css_class' => 'col-visibility', 'column_css_class' => 'col-visibility'));
     $this->addColumn('status', array('header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->_status->getOptionArray()));
     if (!$this->_storeManager->isSingleStoreMode()) {
         $this->addColumn('websites', array('header' => __('Websites'), 'sortable' => false, 'index' => 'websites', 'type' => 'options', 'options' => $this->_websiteFactory->create()->getCollection()->toOptionHash(), 'header_css_class' => 'col-websites', 'column_css_class' => 'col-websites'));
     }
     $this->addColumn('edit', array('header' => __('Edit'), 'type' => 'action', 'getter' => 'getId', 'actions' => array(array('caption' => __('Edit'), 'url' => array('base' => '*/*/edit', 'params' => array('store' => $this->getRequest()->getParam('store'))), 'field' => 'id')), 'filter' => false, 'sortable' => false, 'index' => 'stores', 'header_css_class' => 'col-action', 'column_css_class' => 'col-action'));
     if ($this->_catalogData->isModuleEnabled('Magento_Rss')) {
         $this->addRssList('rss/catalog/notifystock', __('Notify Low Stock RSS'));
     }
     return parent::_prepareColumns();
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function getOptionArray()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getOptionArray');
     if (!$pluginInfo) {
         return parent::getOptionArray();
     } else {
         return $this->___callPlugins('getOptionArray', func_get_args(), $pluginInfo);
     }
 }
Example #5
0
 /**
  * Define Cooser Grid Columns and filters
  *
  * @return $this
  */
 protected function _prepareColumns()
 {
     $this->addColumn('in_products', array('header_css_class' => 'a-center', 'type' => 'checkbox', 'name' => 'in_products', 'values' => $this->_getSelectedProducts(), 'align' => 'center', 'index' => 'sku', 'use_index' => true));
     $this->addColumn('entity_id', array('header' => __('ID'), 'sortable' => true, 'width' => '60px', 'index' => 'entity_id'));
     $this->addColumn('type', array('header' => __('Type'), 'width' => '60px', 'index' => 'type_id', 'type' => 'options', 'options' => $this->_catalogType->getOptionArray()));
     $sets = $this->_eavAttSetCollection->create()->setEntityTypeFilter($this->_catalogProduct->create()->getResource()->getTypeId())->load()->toOptionHash();
     $this->addColumn('set_name', array('header' => __('Attribute Set'), 'width' => '100px', 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets));
     $this->addColumn('chooser_sku', array('header' => __('SKU'), 'name' => 'chooser_sku', 'width' => '80px', 'index' => 'sku'));
     $this->addColumn('chooser_name', array('header' => __('Product'), 'name' => 'chooser_name', 'index' => 'name'));
     return parent::_prepareColumns();
 }
Example #6
0
 /**
  * Prepare grid columns
  *
  * @return $this
  */
 protected function _prepareColumns()
 {
     $this->addColumn('id', ['header' => __('ID'), 'sortable' => true, 'width' => '60px', 'index' => 'entity_id']);
     $this->addColumn('name', ['header' => __('Product'), 'index' => 'name', 'column_css_class' => 'name']);
     $sets = $this->_eavCollectionFactory->create()->setEntityTypeFilter($this->_productFactory->create()->getResource()->getTypeId())->load()->toOptionHash();
     $this->addColumn('type', ['header' => __('Type'), 'width' => '60px', 'index' => 'type_id', 'type' => 'options', 'options' => $this->_productType->getOptionArray()]);
     $this->addColumn('set_name', ['header' => __('Attribute Set'), 'width' => '100px', 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets]);
     $this->addColumn('sku', ['header' => __('SKU'), 'width' => '80px', 'index' => 'sku', 'column_css_class' => 'sku']);
     $this->addColumn('price', ['header' => __('Price'), 'align' => 'center', 'type' => 'currency', 'currency_code' => $this->_getStore()->getDefaultCurrencyCode(), 'rate' => $this->_getStore()->getBaseCurrency()->getRate($this->_getStore()->getDefaultCurrencyCode()), 'index' => 'price']);
     return parent::_prepareColumns();
 }
Example #7
0
 /**
  * Add columns to grid
  *
  * @return $this
  */
 protected function _prepareColumns()
 {
     if (!$this->getProduct()->getUpsellReadonly()) {
         $this->addColumn('in_products', array('type' => 'checkbox', 'name' => 'in_products', 'values' => $this->_getSelectedProducts(), 'align' => 'center', 'index' => 'entity_id', 'header_css_class' => 'col-select', 'column_css_class' => 'col-select'));
     }
     $this->addColumn('entity_id', array('header' => __('ID'), 'sortable' => true, 'index' => 'entity_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id'));
     $this->addColumn('name', array('header' => __('Name'), 'index' => 'name', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name'));
     $this->addColumn('type', array('header' => __('Type'), 'index' => 'type_id', 'type' => 'options', 'options' => $this->_type->getOptionArray(), 'header_css_class' => 'col-type', 'column_css_class' => 'col-type'));
     $sets = $this->_setsFactory->create()->setEntityTypeFilter($this->_productFactory->create()->getResource()->getTypeId())->load()->toOptionHash();
     $this->addColumn('set_name', array('header' => __('Attribute Set'), 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets, 'header_css_class' => 'col-attr-name', 'column_css_class' => 'col-attr-name'));
     $this->addColumn('status', array('header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->_status->getOptionArray(), 'header_css_class' => 'col-status', 'column_css_class' => 'col-status'));
     $this->addColumn('visibility', array('header' => __('Visibility'), 'index' => 'visibility', 'type' => 'options', 'options' => $this->_visibility->getOptionArray(), 'header_css_class' => 'col-visibility', 'column_css_class' => 'col-visibility'));
     $this->addColumn('sku', array('header' => __('SKU'), 'index' => 'sku', 'header_css_class' => 'col-sku', 'column_css_class' => 'col-sku'));
     $this->addColumn('price', array('header' => __('Price'), 'type' => 'currency', 'currency_code' => (string) $this->_scopeConfig->getValue(\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_BASE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE), 'index' => 'price', 'header_css_class' => 'col-price', 'column_css_class' => 'col-price'));
     $this->addColumn('position', array('header' => __('Position'), 'name' => 'position', 'type' => 'number', 'validate_class' => 'validate-number', 'index' => 'position', 'editable' => !$this->getProduct()->getUpsellReadonly(), 'edit_only' => !$this->getProduct()->getId(), 'header_css_class' => 'col-position', 'column_css_class' => 'col-position', 'filter_condition_callback' => array($this, 'filterProductPosition')));
     return parent::_prepareColumns();
 }
Example #8
0
 /**
  * @return $this
  */
 protected function _prepareColumns()
 {
     $this->addColumn('in_products', ['header_css_class' => 'a-center', 'type' => 'checkbox', 'name' => 'in_products', 'values' => $this->_getSelectedProducts(), 'align' => 'center', 'index' => 'entity_id']);
     $this->addColumn('entity_id', ['header' => __('ID'), 'sortable' => true, 'index' => 'entity_id', 'type' => 'number', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id']);
     $this->addColumn('name', ['header' => __('Name'), 'index' => 'product_name', 'header_css_class' => 'col-name', 'column_css_class' => 'col-name']);
     $this->addColumn('type', ['header' => __('Type'), 'index' => 'type_id', 'type' => 'options', 'options' => $this->type->getOptionArray(), 'header_css_class' => 'col-type', 'column_css_class' => 'col-type']);
     /** @var \Magento\Catalog\Model\Resource\Product $resource */
     $resource = $this->productFactory->create()->getResource();
     $sets = $this->setCollectionFactory->create()->setEntityTypeFilter($resource->getTypeId())->load()->toOptionHash();
     $this->addColumn('set_name', ['header' => __('Attribute Set'), 'index' => 'attribute_set_id', 'type' => 'options', 'options' => $sets, 'header_css_class' => 'col-attr-name', 'column_css_class' => 'col-attr-name']);
     $this->addColumn('status', ['header' => __('Status'), 'index' => 'status', 'type' => 'options', 'options' => $this->status->getOptionArray(), 'header_css_class' => 'col-status', 'column_css_class' => 'col-status']);
     $this->addColumn('visibility', ['header' => __('Visibility'), 'index' => 'visibility', 'type' => 'options', 'options' => $this->visibility->getOptionArray(), 'header_css_class' => 'col-visibility', 'column_css_class' => 'col-visibility']);
     $this->addColumn('sku', ['header' => __('SKU'), 'index' => 'sku', 'header_css_class' => 'col-sku', 'column_css_class' => 'col-sku']);
     $this->addColumn('price', ['header' => __('Price'), 'type' => 'currency', 'currency_code' => (string) $this->_scopeConfig->getValue(Currency::XML_PATH_CURRENCY_BASE, ScopeInterface::SCOPE_STORE), 'index' => 'price', 'header_css_class' => 'col-price', 'column_css_class' => 'col-price']);
     $this->addColumn('position', ['header' => __('Position'), 'name' => 'position', 'width' => 60, 'type' => 'number', 'validate_class' => 'validate-number', 'index' => 'position', 'editable' => true]);
     return $this;
 }
Example #9
0
 public function testGetOptionArray()
 {
     $this->assertEquals($this->getOptionArray(), $this->_model->getOptionArray());
 }