Example #1
0
 /**
  * Load Wysiwyg on demand and prepare layout
  *
  * @return void
  */
 protected function _prepareLayout()
 {
     parent::_prepareLayout();
     if ($this->_catalogData->isModuleEnabled('Magento_Cms') && $this->_wysiwygConfig->isEnabled()) {
         $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
     }
 }
Example #2
0
 /**
  * @return Grid
  */
 protected function _prepareCollection()
 {
     $productId = $this->getRequest()->getParam('id');
     $websiteId = 0;
     if ($store = $this->getRequest()->getParam('store')) {
         $websiteId = $this->_storeManager->getStore($store)->getWebsiteId();
     }
     if ($this->_catalogData->isModuleEnabled('Magento_ProductAlert')) {
         $collection = $this->_priceFactory->create()->getCustomerCollection()->join($productId, $websiteId);
         $this->setCollection($collection);
     }
     return parent::_prepareCollection();
 }
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
 /**
  * Retrieve stock option array
  *
  * @return array
  */
 public function getStockOption()
 {
     if ($this->catalogData->isModuleEnabled('Magento_CatalogInventory')) {
         return $this->stock->toOptionArray();
     }
     return array();
 }
Example #5
0
 /**
  * Retrieve allowed customer groups
  *
  * @param int|null $groupId  return name by customer group id
  * @return array|string
  */
 public function getCustomerGroups($groupId = null)
 {
     if ($this->_customerGroups === null) {
         if (!$this->_catalogData->isModuleEnabled('Magento_Customer')) {
             return array();
         }
         $groups = $this->_groupService->getGroups();
         $this->_customerGroups = $this->_getInitialCustomerGroups();
         foreach ($groups as $group) {
             $this->_customerGroups[$group->getId()] = $group->getCode();
         }
     }
     if ($groupId !== null) {
         return isset($this->_customerGroups[$groupId]) ? $this->_customerGroups[$groupId] : array();
     }
     return $this->_customerGroups;
 }
Example #6
0
 /**
  * Join prices from price rules to products collection
  *
  * @return $this
  */
 protected function _joinPriceRules()
 {
     if ($this->isEnabledFlat()) {
         $customerGroup = $this->_customerSession->getCustomerGroupId();
         $priceColumn = 'e.display_price_group_' . $customerGroup;
         $this->getSelect()->columns(array('_rule_price' => $priceColumn));
         return $this;
     }
     if (!$this->_catalogData->isModuleEnabled('Magento_CatalogRule')) {
         return $this;
     }
     $wId = $this->_storeManager->getWebsite()->getId();
     $gId = $this->_customerSession->getCustomerGroupId();
     $storeDate = $this->_localeDate->scopeTimeStamp($this->getStoreId());
     $conditions = 'price_rule.product_id = e.entity_id AND ';
     $conditions .= "price_rule.rule_date = '" . $this->dateTime->formatDate($storeDate, false) . "' AND ";
     $conditions .= $this->getConnection()->quoteInto('price_rule.website_id = ? AND', $wId);
     $conditions .= $this->getConnection()->quoteInto('price_rule.customer_group_id = ?', $gId);
     $this->getSelect()->joinLeft(array('price_rule' => $this->getTable('catalogrule_product_price')), $conditions, array('rule_price' => 'rule_price'));
     return $this;
 }
Example #7
0
 /**
  * Same as setData(), but also initiates the stock item (if it is there)
  *
  * @param array $data Array to form the object from
  * @return \Magento\Catalog\Model\Product
  */
 public function fromArray($data)
 {
     if (isset($data['stock_item'])) {
         if ($this->_catalogData->isModuleEnabled('Magento_CatalogInventory')) {
             $stockItem = $this->_stockItemFactory->create()->setData($data['stock_item'])->setProduct($this);
             $this->setStockItem($stockItem);
         }
         unset($data['stock_item']);
     }
     $this->setData($data);
     return $this;
 }