예제 #1
0
 protected function _prepareCollection()
 {
     /** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
     $connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
     // Prepare selling format collection
     // ---------------------------------------
     $collectionSellingFormat = Mage::getModel('M2ePro/Template_SellingFormat')->getCollection();
     $collectionSellingFormat->getSelect()->reset(Varien_Db_Select::COLUMNS);
     $collectionSellingFormat->getSelect()->columns(array('id as template_id', 'title', new Zend_Db_Expr('\'' . self::TEMPLATE_SELLING_FORMAT . '\' as `type`'), 'create_date', 'update_date'));
     $collectionSellingFormat->getSelect()->where('component_mode = (?)', $this->nick);
     // ---------------------------------------
     // Prepare synchronization collection
     // ---------------------------------------
     $collectionSynchronization = Mage::getModel('M2ePro/Template_Synchronization')->getCollection();
     $collectionSynchronization->getSelect()->reset(Varien_Db_Select::COLUMNS);
     $collectionSynchronization->getSelect()->columns(array('id as template_id', 'title', new Zend_Db_Expr('\'' . self::TEMPLATE_SYNCHRONIZATION . '\' as `type`'), 'create_date', 'update_date'));
     $collectionSynchronization->getSelect()->where('component_mode = (?)', $this->nick);
     // ---------------------------------------
     // Prepare union select
     // ---------------------------------------
     $unionSelect = $connRead->select();
     $unionSelect->union(array($collectionSellingFormat->getSelect(), $collectionSynchronization->getSelect()));
     // ---------------------------------------
     // Prepare result collection
     // ---------------------------------------
     $resultCollection = new Varien_Data_Collection_Db($connRead);
     $resultCollection->getSelect()->reset()->from(array('main_table' => $unionSelect), array('template_id', 'title', 'type', 'create_date', 'update_date'));
     // ---------------------------------------
     //        echo $resultCollection->getSelectSql(true); exit;
     $this->setCollection($resultCollection);
     return parent::_prepareCollection();
 }
예제 #2
0
 protected function _prepareCollection()
 {
     /** @var $connRead Varien_Db_Adapter_Pdo_Mysql */
     $connRead = Mage::getSingleton('core/resource')->getConnection('core_read');
     // Prepare selling format collection
     // ---------------------------------------
     $collectionSellingFormat = Mage::getModel('M2ePro/Template_SellingFormat')->getCollection();
     $collectionSellingFormat->getSelect()->reset(Varien_Db_Select::COLUMNS);
     $collectionSellingFormat->getSelect()->columns(array('id as template_id', 'title', new Zend_Db_Expr('\'' . self::TEMPLATE_SELLING_FORMAT . '\' as `type`'), new Zend_Db_Expr('\'0\' as `marketplace_id`'), 'create_date', 'update_date', new Zend_Db_Expr('NULL as `category_path`'), new Zend_Db_Expr('NULL as `browsenode_id`'), new Zend_Db_Expr('NULL as `is_new_asin_accepted`')));
     $collectionSellingFormat->getSelect()->where('component_mode = (?)', $this->nick);
     // ---------------------------------------
     // Prepare synchronization collection
     // ---------------------------------------
     $collectionSynchronization = Mage::getModel('M2ePro/Template_Synchronization')->getCollection();
     $collectionSynchronization->getSelect()->reset(Varien_Db_Select::COLUMNS);
     $collectionSynchronization->getSelect()->columns(array('id as template_id', 'title', new Zend_Db_Expr('\'' . self::TEMPLATE_SYNCHRONIZATION . '\' as `type`'), new Zend_Db_Expr('\'0\' as `marketplace_id`'), 'create_date', 'update_date', new Zend_Db_Expr('NULL as `category_path`'), new Zend_Db_Expr('NULL as `browsenode_id`'), new Zend_Db_Expr('NULL as `is_new_asin_accepted`')));
     $collectionSynchronization->getSelect()->where('component_mode = (?)', $this->nick);
     // ---------------------------------------
     // Prepare shipping override collection
     // ---------------------------------------
     $collectionShippingOverride = Mage::getModel('M2ePro/Amazon_Template_ShippingOverride')->getCollection();
     $collectionShippingOverride->getSelect()->reset(Varien_Db_Select::COLUMNS);
     $collectionShippingOverride->getSelect()->columns(array('id as template_id', 'title', new Zend_Db_Expr('\'' . self::TEMPLATE_SHIPPING_OVERRIDE . '\' as `type`'), 'marketplace_id', 'create_date', 'update_date', new Zend_Db_Expr('NULL as `category_path`'), new Zend_Db_Expr('NULL as `browsenode_id`'), new Zend_Db_Expr('NULL as `is_new_asin_accepted`')));
     // ---------------------------------------
     // Prepare shipping override collection
     // ---------------------------------------
     $collectionDescription = Mage::helper('M2ePro/Component_Amazon')->getCollection('Template_Description');
     $collectionDescription->getSelect()->join(array('mm' => Mage::getModel('M2ePro/Marketplace')->getResource()->getMainTable()), 'mm.id=second_table.marketplace_id', array());
     $collectionDescription->addFieldToFilter('mm.status', Ess_M2ePro_Model_Marketplace::STATUS_ENABLE);
     $collectionDescription->getSelect()->reset(Varien_Db_Select::COLUMNS);
     $collectionDescription->getSelect()->columns(array('id as template_id', 'title', new Zend_Db_Expr('\'' . self::TEMPLATE_DESCRIPTION . '\' as `type`'), 'second_table.marketplace_id', 'create_date', 'update_date', 'second_table.category_path', 'second_table.browsenode_id', 'second_table.is_new_asin_accepted'));
     // ---------------------------------------
     // Prepare union select
     // ---------------------------------------
     $unionSelect = $connRead->select();
     $unionSelect->union(array($collectionSellingFormat->getSelect(), $collectionSynchronization->getSelect(), $collectionDescription->getSelect(), $collectionShippingOverride->getSelect()));
     // ---------------------------------------
     // Prepare result collection
     // ---------------------------------------
     $resultCollection = new Varien_Data_Collection_Db($connRead);
     $resultCollection->getSelect()->reset()->from(array('main_table' => $unionSelect), array('template_id', 'title', 'type', 'marketplace_id', 'create_date', 'update_date', 'category_path', 'browsenode_id', 'is_new_asin_accepted'));
     // ---------------------------------------
     //        echo $resultCollection->getSelectSql(true); exit;
     $this->setCollection($resultCollection);
     return parent::_prepareCollection();
 }