Пример #1
0
 /**
  * Unserialize additional_information in each item
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     foreach ($this->_items as $item) {
         $this->getResource()->unserializeFields($item);
     }
     return parent::_afterLoad();
 }
Пример #2
0
 /**
  * Add website ids to rules data
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     parent::_afterLoad();
     if ($this->getFlag('add_websites_to_result') && $this->_items) {
         /** @var \Magento\Rule\Model\AbstractModel $item */
         foreach ($this->_items as $item) {
             $item->afterLoad();
         }
     }
     return $this;
 }
Пример #3
0
 /**
  * Set parent items
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     parent::_afterLoad();
     /**
      * Assign parent items
      */
     foreach ($this as $item) {
         if ($item->getParentItemId()) {
             $item->setParentItem($this->getItemById($item->getParentItemId()));
         }
     }
     return $this;
 }
Пример #4
0
 /**
  * Fill array of options by item and product
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     parent::_afterLoad();
     foreach ($this as $option) {
         $optionId = $option->getId();
         $itemId = $option->getItemId();
         $productId = $option->getProductId();
         if (isset($this->_optionsByItem[$itemId])) {
             $this->_optionsByItem[$itemId][] = $optionId;
         } else {
             $this->_optionsByItem[$itemId] = [$optionId];
         }
         if (isset($this->_optionsByProduct[$productId])) {
             $this->_optionsByProduct[$productId][] = $optionId;
         } else {
             $this->_optionsByProduct[$productId] = [$optionId];
         }
     }
     return $this;
 }
Пример #5
0
 /**
  * After load collection process
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     parent::_afterLoad();
     \Magento\Framework\Profiler::start('TTT1:' . __METHOD__, array('group' => 'TTT1', 'method' => __METHOD__));
     $this->_addProductAttributes();
     \Magento\Framework\Profiler::stop('TTT1:' . __METHOD__);
     \Magento\Framework\Profiler::start('TTT2:' . __METHOD__, array('group' => 'TTT2', 'method' => __METHOD__));
     $this->_addAssociatedProductFilters();
     \Magento\Framework\Profiler::stop('TTT2:' . __METHOD__);
     \Magento\Framework\Profiler::start('TTT3:' . __METHOD__, array('group' => 'TTT3', 'method' => __METHOD__));
     $this->_loadLabels();
     \Magento\Framework\Profiler::stop('TTT3:' . __METHOD__);
     \Magento\Framework\Profiler::start('TTT4:' . __METHOD__, array('group' => 'TTT4', 'method' => __METHOD__));
     $this->_loadPrices();
     \Magento\Framework\Profiler::stop('TTT4:' . __METHOD__);
     return $this;
 }
Пример #6
0
 /**
  * After load processing
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     parent::_afterLoad();
     /**
      * Assign parent items
      */
     foreach ($this as $item) {
         if ($item->getParentItemId()) {
             $item->setParentItem($this->getItemById($item->getParentItemId()));
         }
         if ($this->_quote) {
             $item->setQuote($this->_quote);
         }
     }
     /**
      * Assign options and products
      */
     $this->_assignOptions();
     $this->_assignProducts();
     $this->resetItemsDataChanged();
     return $this;
 }
Пример #7
0
 /**
  * Perform operations after collection load
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     $items = $this->getColumnValues('page_id');
     if (count($items)) {
         $connection = $this->getConnection();
         $select = $connection->select()->from(['cps' => $this->getTable('cms_page_store')])->where('cps.page_id IN (?)', $items);
         $result = $connection->fetchPairs($select);
         if ($result) {
             foreach ($this as $item) {
                 $pageId = $item->getData('page_id');
                 if (!isset($result[$pageId])) {
                     continue;
                 }
                 if ($result[$pageId] == 0) {
                     $stores = $this->_storeManager->getStores(false, true);
                     $storeId = current($stores)->getId();
                     $storeCode = key($stores);
                 } else {
                     $storeId = $result[$item->getData('page_id')];
                     $storeCode = $this->_storeManager->getStore($storeId)->getCode();
                 }
                 $item->setData('_first_store_id', $storeId);
                 $item->setData('store_code', $storeCode);
                 $item->setData('store_id', [$result[$pageId]]);
             }
         }
     }
     $this->_previewFlag = false;
     return parent::_afterLoad();
 }
Пример #8
0
 /**
  * Redeclare after load method for dispatch event
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     parent::_afterLoad();
     $this->_eventManager->dispatch($this->_eventPrefix . '_load_after', array($this->_eventObject => $this));
     return $this;
 }
Пример #9
0
 /**
  * After collection load
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     $this->_eventManager->dispatch($this->_eventPrefix . '_load_after', [$this->_eventObject => $this]);
     return parent::_afterLoad();
 }
Пример #10
0
 /**
  * After load processing
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     parent::_afterLoad();
     /**
      * Assign products
      */
     $this->_assignOptions();
     $this->_assignProducts();
     $this->resetItemsDataChanged();
     $this->getPageSize();
     return $this;
 }
Пример #11
0
 /**
  * @return \Magento\Cms\Model\Resource\Block\Grid\Collection
  */
 protected function _afterLoad()
 {
     $this->walk('afterLoad');
     parent::_afterLoad();
 }
Пример #12
0
 /**
  * Add data fetched from another database
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     parent::_afterLoad();
     $items = $this->getItems();
     $productIds = [];
     foreach ($items as $item) {
         $productIds[] = $item->getProductId();
     }
     $productData = $this->getProductData($productIds);
     $orderData = $this->getOrdersData($productIds);
     foreach ($items as $item) {
         $item->setId($item->getProductId());
         $item->setPrice($productData[$item->getProductId()]['price'] * $item->getBaseToGlobalRate());
         $item->setName($productData[$item->getProductId()]['name']);
         $item->setOrders(0);
         if (isset($orderData[$item->getProductId()])) {
             $item->setOrders($orderData[$item->getProductId()]['orders']);
         }
     }
     return $this;
 }
Пример #13
0
 /**
  * after collection load
  *
  * @return $this
  */
 protected function _afterLoad()
 {
     $items = $this->getColumnValues('author_id');
     $connection = $this->getConnection();
     if (count($items)) {
         $select = $connection->select()->from(['author_store' => $this->getTable('sample_news_author_store')])->where('author_store.author_id IN (?)', $items);
         if ($result = $connection->fetchPairs($select)) {
             foreach ($this as $item) {
                 /** @var $item \Sample\News\Model\Author */
                 if (!isset($result[$item->getData('author_id')])) {
                     continue;
                 }
                 $item->setData('store_id', $result[$item->getData('author_id')]);
             }
         }
     }
     return parent::_afterLoad();
 }