Example #1
0
 protected function _prepareCollection()
 {
     $listingData = $this->getHelper('Data\\GlobalData')->getValue('temp_data');
     // Get collection logs
     // ---------------------------------------
     $collection = $this->activeRecordFactory->getObject('Listing\\Other\\Log')->getCollection();
     // ---------------------------------------
     // Join amazon_listings_table
     // ---------------------------------------
     $collection->getSelect()->joinLeft(array('lo' => $this->activeRecordFactory->getObject('Listing\\Other')->getResource()->getMainTable()), '(`main_table`.listing_other_id = `lo`.id)', array('account_id' => 'lo.account_id', 'marketplace_id' => 'lo.marketplace_id'))->joinLeft(array('ea' => $this->activeRecordFactory->getObject('Ebay\\Account')->getResource()->getMainTable()), '(`lo`.account_id = `ea`.account_id)', array('account_mode' => 'ea.mode'));
     // ---------------------------------------
     // Set listing filter
     // ---------------------------------------
     if (isset($listingData['id'])) {
         $collection->addFieldToFilter('main_table.listing_other_id', $listingData['id']);
     }
     // ---------------------------------------
     // prepare components
     // ---------------------------------------
     $component = $this->getRequest()->getParam('channel', false);
     if (!$component) {
         $component = $this->getComponentMode();
     }
     if (!empty($component) && $component != \Ess\M2ePro\Block\Adminhtml\Amazon\Log\Tabs::CHANNEL_ID_ALL) {
         $collection->getSelect()->where('main_table.component_mode = ?', $component);
         $accountId = (int) $this->getRequest()->getParam($component . 'Account', false);
         $marketplaceId = (int) $this->getRequest()->getParam($component . 'Marketplace', false);
         if ($accountId) {
             $collection->getSelect()->where('lo.account_id = ?', $accountId);
         }
         if ($marketplaceId) {
             $collection->getSelect()->where('lo.marketplace_id = ?', $marketplaceId);
         }
     } else {
         $collection->getSelect()->where('main_table.component_mode IS NULL');
     }
     // ---------------------------------------
     // we need sort by id also, because create_date may be same for some adjacents entries
     // ---------------------------------------
     if ($this->getRequest()->getParam('sort', 'create_date') == 'create_date') {
         $collection->setOrder('id', $this->getRequest()->getParam('dir', 'DESC'));
     }
     // ---------------------------------------
     // Set collection to grid
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }
Example #2
0
 protected function _prepareCollection()
 {
     // Get collection logs
     // ---------------------------------------
     $collection = $this->activeRecordFactory->getObject('Synchronization\\Log')->getCollection();
     // ---------------------------------------
     $collection->getSelect()->reset(\Zend_Db_Select::COLUMNS);
     $collection->getSelect()->columns(['create_date', 'task', 'description', 'type']);
     $ebayComponent = $this->getHelper('View\\Ebay\\Component')->getEnabledComponents();
     $amazonComponent = $this->getHelper('View\\Amazon\\Component')->getEnabledComponents();
     $components = array_merge($ebayComponent, $amazonComponent);
     $collection->getSelect()->where('component_mode IN(\'' . implode('\',\'', $components) . '\') OR component_mode IS NULL');
     // we need sort by id also, because create_date may be same for some adjacents entries
     // ---------------------------------------
     if ($this->getRequest()->getParam('sort', 'create_date') == 'create_date') {
         $collection->setOrder('id', $this->getRequest()->getParam('dir', 'DESC'));
     }
     // ---------------------------------------
     // Set collection to grid
     $this->setCollection($collection);
     return parent::_prepareCollection();
 }