• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Varien_Data_Collection_Db类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Varien_Data_Collection_Db的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Data_Collection_Db类的具体用法?PHP Varien_Data_Collection_Db怎么用?PHP Varien_Data_Collection_Db使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Varien_Data_Collection_Db类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: addCustomAttributes

 /**
  * Add custom attributes selected by magento admin to query
  *
  * @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
  * @param string $customAttribs Comma separated list of attribute codes
  * @param array $fieldMap Reference to fieldmap where attribute codes should also be added
  */
 protected function addCustomAttributes($collection, $customAttribs, &$fieldMap)
 {
     // Log
     Mage::helper('mybuys')->log("Adding custom attributes include in query: {$customAttribs}", Zend_Log::INFO, Mybuys_Connector_Helper_Data::LOG_FILE);
     // Check if we have any custom attribs
     if (strlen(trim($customAttribs)) > 0) {
         // Iterate custom attribs
         foreach (explode(',', $customAttribs) as $curAttrib) {
             // Trim attribute code
             $curAttrib = trim($curAttrib);
             // Check if attribute exists
             $_attribute = $collection->getAttribute($curAttrib);
             if ($_attribute === false) {
                 // Attribute not found
                 Mage::throwException("Attribte not found: {$curAttrib}");
             }
             // Log
             Mage::helper('mybuys')->log("Adding attribute to query: {$curAttrib}", Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
             if ($_attribute->getFrontendInput() == "select" || $_attribute->getFrontendInput() == "multiselect") {
                 // attribute is a select of multi-select input and attribute id to value translation is needed
                 // Log
                 Mage::helper('mybuys')->log("Note - Attribute needs translation", Zend_Log::DEBUG, Mybuys_Connector_Helper_Data::LOG_FILE);
                 $this->_optionValueMap['custom_' . $curAttrib] = true;
             }
             // Add attribute to select
             $collection->addExpressionAttributeToSelect('custom_' . $curAttrib, "{{" . $curAttrib . "}}", $curAttrib)->addAttributeToSelect($curAttrib);
             // Add attribute to map
             $fieldMap['custom_' . $curAttrib] = 'custom_' . $curAttrib;
         }
     }
     // Return the original collection object
     return $collection;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:40,代码来源:Base.php


示例2: _prepareCollection

 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();
 }
开发者ID:ReeceCrossland,项目名称:essua-m2epro,代码行数:32,代码来源:Grid.php


示例3: _prepareCollection

 protected function _prepareCollection()
 {
     // Get collection products in listing
     // ---------------------------------------
     $listingProductCollection = Mage::helper('M2ePro/Component_Buy')->getCollection('Listing_Product');
     $listingProductCollection->getSelect()->distinct();
     $listingProductCollection->getSelect()->join(array('l' => Mage::getResourceModel('M2ePro/Listing')->getMainTable()), '(`l`.`id` = `main_table`.`listing_id`)', array('listing_title' => 'title', 'store_id'))->join(array('bl' => Mage::getResourceModel('M2ePro/Buy_Listing')->getMainTable()), '(`bl`.`listing_id` = `l`.`id`)', array('template_selling_format_id'));
     // ---------------------------------------
     // Communicate with magento product table
     // ---------------------------------------
     $dbSelect = Mage::getResourceModel('core/config')->getReadConnection()->select()->from(Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar'), new Zend_Db_Expr('MAX(`store_id`)'))->where("`entity_id` = `main_table`.`product_id`")->where("`attribute_id` = `ea`.`attribute_id`")->where("`store_id` = 0 OR `store_id` = `l`.`store_id`");
     $listingProductCollection->getSelect()->join(array('cpe' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')), '(cpe.entity_id = `main_table`.product_id)', array('magento_sku' => 'sku'))->join(array('cisi' => Mage::getSingleton('core/resource')->getTableName('cataloginventory_stock_item')), '(cisi.product_id = `main_table`.product_id AND cisi.stock_id = 1)', array('is_in_stock'))->join(array('cpev' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')), "(`cpev`.`entity_id` = `main_table`.product_id)", array('value'))->join(array('ea' => Mage::getSingleton('core/resource')->getTableName('eav_attribute')), '(`cpev`.`attribute_id` = `ea`.`attribute_id` AND `ea`.`attribute_code` = \'name\')', array())->where('`cpev`.`store_id` = (' . $dbSelect->__toString() . ')');
     // ---------------------------------------
     $listingProductCollection->getSelect()->reset(Zend_Db_Select::COLUMNS);
     $listingProductCollection->getSelect()->columns(array('is_m2epro_listing' => new Zend_Db_Expr('1'), 'magento_sku' => 'cpe.sku', 'is_in_stock' => 'cisi.is_in_stock', 'product_name' => 'cpev.value', 'listing_title' => 'l.title', 'store_id' => 'l.store_id', 'account_id' => 'l.account_id', 'marketplace_id' => 'l.marketplace_id', 'listing_product_id' => 'main_table.id', 'product_id' => 'main_table.product_id', 'listing_id' => 'main_table.listing_id', 'status' => 'main_table.status', 'template_new_product_id' => 'second_table.template_new_product_id', 'general_id' => 'second_table.general_id', 'online_sku' => 'second_table.sku', 'online_qty' => 'second_table.online_qty', 'online_price' => 'second_table.online_price'));
     // ---------------------------------------
     $listingOtherCollection = Mage::helper('M2ePro/Component_Buy')->getCollection('Listing_Other');
     $listingOtherCollection->getSelect()->distinct();
     // add stock availability, type id, status & visibility to select
     // ---------------------------------------
     $listingOtherCollection->getSelect()->joinLeft(array('cisi' => Mage::getResourceModel('cataloginventory/stock_item')->getMainTable()), '(`cisi`.`product_id` = `main_table`.`product_id` AND cisi.stock_id = 1)', array('is_in_stock'))->joinLeft(array('cpe' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')), '(cpe.entity_id = `main_table`.product_id)', array('magento_sku' => 'sku'));
     // ---------------------------------------
     $listingOtherCollection->getSelect()->reset(Zend_Db_Select::COLUMNS);
     $listingOtherCollection->getSelect()->columns(array('is_m2epro_listing' => new Zend_Db_Expr(0), 'magento_sku' => 'cpe.sku', 'is_in_stock' => 'cisi.is_in_stock', 'product_name' => 'second_table.title', 'listing_title' => new Zend_Db_Expr('NULL'), 'store_id' => new Zend_Db_Expr(0), 'account_id' => 'main_table.account_id', 'marketplace_id' => 'main_table.marketplace_id', 'listing_product_id' => new Zend_Db_Expr('NULL'), 'product_id' => 'main_table.product_id', 'listing_id' => new Zend_Db_Expr('NULL'), 'status' => 'main_table.status', 'template_new_product_id' => new Zend_Db_Expr('NULL'), 'general_id' => 'second_table.general_id', 'online_sku' => 'second_table.sku', 'online_qty' => 'second_table.online_qty', 'online_price' => 'second_table.online_price'));
     // ---------------------------------------
     // ---------------------------------------
     $selects = array($listingProductCollection->getSelect(), $listingOtherCollection->getSelect());
     $unionSelect = Mage::getResourceModel('core/config')->getReadConnection()->select();
     $unionSelect->union($selects);
     $resultCollection = new Varien_Data_Collection_Db(Mage::getResourceModel('core/config')->getReadConnection());
     $resultCollection->getSelect()->reset()->from(array('main_table' => $unionSelect), array('is_m2epro_listing', 'magento_sku', 'is_in_stock', 'product_name', 'listing_title', 'store_id', 'account_id', 'marketplace_id', 'listing_product_id', 'product_id', 'listing_id', 'status', 'template_new_product_id', 'general_id', 'online_sku', 'online_qty', 'online_price'));
     // Set collection to grid
     $this->setCollection($resultCollection);
     return parent::_prepareCollection();
 }
开发者ID:giuseppemorelli,项目名称:magento-extension,代码行数:35,代码来源:Grid.php


示例4: _prepareCollection

 /**
  * Adding item data using second query because:
  *
  * - Join causes use of temporary table == slow
  * - Wrapping the main query as a subquery is too complex
  * - We want to show all order items for orders that matched filter by sku/name
  *
  * @return $this
  */
 protected function _prepareCollection()
 {
     parent::_prepareCollection();
     if (Mage::getStoreConfig(self::XML_PATH_RENDER_COLUMN) && !$this->_isExport) {
         $orderIds = array();
         $orderCollection = $this->getCollection();
         /** @var $orderCollection Mage_Sales_Model_Mysql4_Order_Grid_Collection */
         foreach ($orderCollection as $order) {
             $orderIds[] = $order->getEntityId();
         }
         $conn = Mage::getSingleton('core/resource')->getConnection('read');
         /* @var $conn Zend_Db_Adapter_Pdo_Abstract */
         // Increase max length of group concat fields for long product names
         $conn->exec('SET SESSION group_concat_max_len = 4096;');
         $itemsCollection = new Varien_Data_Collection_Db($conn);
         $itemsCollection->getSelect()->from(array('soi' => $orderCollection->getTable('sales/order_item')), array('order_id', 'skus' => new Zend_Db_Expr('group_concat(`soi`.sku SEPARATOR " ^ ")'), 'qtys' => new Zend_Db_Expr('group_concat(`soi`.qty_ordered SEPARATOR " ^ ")'), 'names' => new Zend_Db_Expr('group_concat(`soi`.name SEPARATOR " ^ ")')))->where('order_id IN (?)', $orderIds)->group('order_id');
         foreach ($itemsCollection as $object) {
             $order = $orderCollection->getItemById($object->getOrderId());
             $order->setSkus($object->getSkus());
             $order->setQtys($object->getQtys());
             $order->setNames($object->getNames());
         }
     }
     Mage::app()->dispatchEvent('cm_orderproducts_sales_order_grid_prepareCollection', ['block' => $this]);
     return $this;
 }
开发者ID:martinhelfert,项目名称:Cm_OrderProducts,代码行数:35,代码来源:Grid.php


示例5: addMotorsSpecificsAttributeToSelect

 private function addMotorsSpecificsAttributeToSelect(Varien_Data_Collection_Db $collection)
 {
     if (!$this->isMotorsSpecificsAttributeAvailable()) {
         return;
     }
     $attribute = $this->getMotorsSpecificsAttribute();
     $attributeId = (int) $attribute->getAttributeId();
     $collection->getSelect()->joinLeft(array('cpet' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_text')), '(`cpet`.`entity_id` = `main_table`.product_id AND `cpet`.`attribute_id` = ' . $attributeId . ')', array('motors_specifics_attribute_value' => 'value'));
 }
开发者ID:xiaoguizhidao,项目名称:beut,代码行数:9,代码来源:Grid.php


示例6: applyLogToCollection

 /**
  * Add events log to a collection
  * The collection id field is used without corellation, so it must be unique.
  * DESC ordering by event will be added to the collection
  *
  * @param Varien_Data_Collection_Db $collection
  * @param int $eventTypeId
  * @param int $eventSubjectId
  * @param int $subtype
  * @param array $skipIds
  */
 public function applyLogToCollection(Varien_Data_Collection_Db $collection, $eventTypeId, $eventSubjectId, $subtype, $skipIds = array())
 {
     $idFieldName = $collection->getResource()->getIdFieldName();
     $derivedSelect = $this->getReadConnection()->select()->from($this->getTable('reports/event'), array('event_id' => new Zend_Db_Expr('MAX(event_id)'), 'object_id'))->where('event_type_id=?', (int) $eventTypeId)->where('subject_id=?', (int) $eventSubjectId)->where('subtype=?', (int) $subtype)->where('store_id IN(?)', $this->getCurrentStoreIds())->group('object_id');
     if ($skipIds) {
         if (!is_array($skipIds)) {
             $skipIds = array((int) $skipIds);
         }
         $derivedSelect->where('object_id NOT IN(?)', $skipIds);
     }
     $collection->getSelect()->joinInner(array('evt' => new Zend_Db_Expr("({$derivedSelect})")), "`{$idFieldName}`=evt.object_id", array())->order('evt.event_id DESC');
 }
开发者ID:hunnybohara,项目名称:magento-chinese-localization,代码行数:23,代码来源:Event.php


示例7: addThrottleFilter

 /**
  * Add throttle parameter to collection to limit output to X number of rows
  *
  * @param Varien_Data_Collection_Db $collection Collection of data which will be spit out as feed
  * @param int|string $throttle Number representing maximum record count which should be included in this feed generation run
  * @param int|string $minEntityId Number representing minimum value for entity Id to export - This acts as a placeholder for where the feed export left off
  */
 protected function addThrottleFilter($collection, $throttle, $minEntityId)
 {
     // Add mim entity id filter
     if ($minEntityId > 0) {
         $collection->getSelect()->where("product_id >= {$minEntityId}");
     }
     // Add throttle param
     if ($throttle > 0) {
         $collection->getSelect()->limit($throttle);
     }
     // Return the modified collection
     return $collection;
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:20,代码来源:Crosssell.php


示例8: addStatusFilterToOrders

 /**
  * Filter an order collection by status/state depending on MailUp config
  * NOTE that cannot override collection consistently as the class changed name in 1.6
  *
  * @param Varien_Data_Collection_Db $collection
  * @return $this
  */
 public function addStatusFilterToOrders($collection)
 {
     $config = Mage::getModel('mailup/config');
     // Add condition to skip orders that have incorrect statuses
     $allowedStatuses = $config->getQualifyingOrderStatuses();
     // If config options, use the given statuses
     if (count($allowedStatuses) > 0) {
         $collection->addAttributeToFilter('status', $allowedStatuses);
     } else {
         // Else, use complete, closed and processing state only
         $allowedStates = $config->getDefaultQualifyingStates();
         $collection->addAttributeToFilter('state', $allowedStates);
     }
     return $this;
 }
开发者ID:hanicker,项目名称:mailup-magento,代码行数:22,代码来源:Order.php


示例9: unlinkEmails

 /**
  * Remove Bronto Message Connection for Template
  *
  * @param Varien_Data_Collection_Db $collection
  * @param string                    $scope
  * @param string|int                $scopeId
  */
 public function unlinkEmails(Varien_Data_Collection_Db $collection, $scope, $scopeId)
 {
     switch ($scope) {
         case 'stores':
         case 'store':
             $storeId = $scopeId;
             break;
         case 'websites':
         case 'website':
             $storeId = Mage::app()->getWebsite($scopeId)->getStoreIds();
             break;
         default:
             $storeId = false;
             break;
     }
     // create filter
     if ($storeId) {
         if (is_array($storeId)) {
             $filter = array('in' => $storeId);
         } else {
             $filter = array('eq' => $storeId);
         }
         $collection->addFieldToFilter('store_id', $filter);
     }
     // Delete Bronto Message connection to template
     foreach ($collection as $message) {
         $message->delete();
     }
 }
开发者ID:xiaoguizhidao,项目名称:blingjewelry-prod,代码行数:36,代码来源:Keysentry.php


示例10: _prepareCollection

 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();
 }
开发者ID:ReeceCrossland,项目名称:essua-m2epro,代码行数:46,代码来源:Grid.php


示例11: attachDataToCollection

 /**
  * Attachs data to collection
  *
  * @param Varien_Data_Collection_Db $collection
  * @return Enterprise_Customer_Model_Resource_Sales_Address_Abstract
  */
 public function attachDataToCollection(Varien_Data_Collection_Db $collection)
 {
     $items = array();
     $itemIds = array();
     foreach ($collection->getItems() as $item) {
         $itemIds[] = $item->getId();
         $items[$item->getId()] = $item;
     }
     if ($itemIds) {
         $select = $this->_getReadAdapter()->select()->from($this->getMainTable())->where("{$this->getIdFieldName()} IN (?)", $itemIds);
         $rowSet = $this->_getReadAdapter()->fetchAll($select);
         foreach ($rowSet as $row) {
             $items[$row[$this->getIdFieldName()]]->addData($row);
         }
     }
     return $this;
 }
开发者ID:hientruong90,项目名称:ee_14_installer,代码行数:23,代码来源:Abstract.php


示例12: _prepareCollection

 protected function _prepareCollection()
 {
     // Get collection products in listing
     //--------------------------------
     $nameAttribute = Mage::getResourceModel('catalog/product')->getAttribute('name');
     $nameAttributeId = $nameAttribute ? (int) $nameAttribute->getId() : 0;
     $listingProductCollection = Mage::helper('M2ePro/Component_Ebay')->getCollection('Listing_Product');
     $listingProductCollection->getSelect()->distinct();
     $listingProductCollection->getSelect()->join(array('l' => Mage::getResourceModel('M2ePro/Listing')->getMainTable()), '`l`.`id` = `main_table`.`listing_id`');
     $listingProductCollection->getSelect()->join(array('em' => Mage::getResourceModel('M2ePro/Ebay_Marketplace')->getMainTable()), '`em`.`marketplace_id` = `l`.`marketplace_id`');
     $listingProductCollection->getSelect()->join(array('cpe' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')), 'cpe.entity_id = `main_table`.product_id');
     $listingProductCollection->getSelect()->joinLeft(array('cpev' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity_varchar')), '`cpev`.`entity_id` = `main_table`.`product_id`' . ' AND `cpev`.`attribute_id` = ' . $nameAttributeId . ' AND `cpev`.`store_id` = 0');
     $listingProductCollection->getSelect()->joinLeft(array('ebit' => Mage::getResourceModel('M2ePro/Ebay_Item')->getMainTable()), '(`ebit`.`id` = `second_table`.`ebay_item_id`)', array('item_id'));
     //------------------------------
     // add stock availability, status & visibility to select
     //------------------------------
     $listingProductCollection->getSelect()->joinLeft(array('cisi' => Mage::getResourceModel('cataloginventory/stock_item')->getMainTable()), '(`cisi`.`product_id` = `main_table`.`product_id` AND `cisi`.`stock_id` = 1)', array('is_in_stock'));
     //------------------------------
     $listingProductCollection->getSelect()->reset(Zend_Db_Select::COLUMNS);
     $listingProductCollection->getSelect()->columns(array('account_id' => 'l.account_id', 'marketplace_id' => 'l.marketplace_id', 'product_id' => 'main_table.product_id', 'product_name' => 'cpev.value', 'product_sku' => 'cpe.sku', 'currency' => 'em.currency', 'ebay_item_id' => 'ebit.item_id', 'status' => 'main_table.status', 'online_sku' => 'second_table.online_sku', 'online_title' => 'second_table.online_title', 'online_qty' => new Zend_Db_Expr('(second_table.online_qty - second_table.online_qty_sold)'), 'online_qty_sold' => 'second_table.online_qty_sold', 'online_buyitnow_price' => 'second_table.online_buyitnow_price', 'listing_id' => 'l.id', 'listing_title' => 'l.title', 'is_m2epro_listing' => new Zend_Db_Expr(1), 'is_in_stock' => 'cisi.is_in_stock'));
     //------------------------------
     //------------------------------
     $listingOtherCollection = Mage::helper('M2ePro/Component_Ebay')->getCollection('Listing_Other');
     $listingOtherCollection->getSelect()->distinct();
     // add stock availability, type id, status & visibility to select
     //------------------------------
     $listingOtherCollection->getSelect()->joinLeft(array('cisi' => Mage::getResourceModel('cataloginventory/stock_item')->getMainTable()), '(`cisi`.`product_id` = `main_table`.`product_id` AND cisi.stock_id = 1)', array('is_in_stock'));
     //------------------------------
     $listingOtherCollection->getSelect()->reset(Zend_Db_Select::COLUMNS);
     $listingOtherCollection->getSelect()->columns(array('account_id' => 'main_table.account_id', 'marketplace_id' => 'main_table.marketplace_id', 'product_id' => 'main_table.product_id', 'product_name' => 'second_table.title', 'product_sku' => 'second_table.sku', 'currency' => 'second_table.currency', 'ebay_item_id' => 'second_table.item_id', 'status' => 'main_table.status', 'online_sku' => new Zend_Db_Expr('NULL'), 'online_title' => new Zend_Db_Expr('NULL'), 'online_qty' => new Zend_Db_Expr('(second_table.online_qty - second_table.online_qty_sold)'), 'online_qty_sold' => 'second_table.online_qty_sold', 'online_buyitnow_price' => 'second_table.online_price', 'listing_id' => new Zend_Db_Expr('NULL'), 'listing_title' => new Zend_Db_Expr('NULL'), 'is_m2epro_listing' => new Zend_Db_Expr(0), 'is_in_stock' => 'cisi.is_in_stock'));
     //------------------------------
     //------------------------------
     $selects = array($listingProductCollection->getSelect());
     if (Mage::helper('M2ePro/View_Ebay')->isAdvancedMode()) {
         $selects[] = $listingOtherCollection->getSelect();
     }
     $unionSelect = Mage::getResourceModel('core/config')->getReadConnection()->select();
     $unionSelect->union($selects);
     $resultCollection = new Varien_Data_Collection_Db(Mage::getResourceModel('core/config')->getReadConnection());
     $resultCollection->getSelect()->reset()->from(array('main_table' => $unionSelect), array('account_id', 'marketplace_id', 'product_id', 'product_name', 'product_sku', 'currency', 'ebay_item_id', 'status', 'online_sku', 'online_title', 'online_qty', 'online_qty_sold', 'online_buyitnow_price', 'listing_id', 'listing_title', 'is_m2epro_listing', 'is_in_stock'));
     //------------------------------
     $this->setCollection($resultCollection);
     //        exit($resultCollection->getSelect().'');
     return parent::_prepareCollection();
 }
开发者ID:ppkowalski,项目名称:M2E,代码行数:45,代码来源:Grid.php


示例13: testClone

 /**
  * Test that after cloning collection $this->_select in initial and cloned collections
  * do not reference the same object
  *
  * @covers Varien_Data_Collection_Db::__clone
  */
 public function testClone()
 {
     $adapter = $this->getMockForAbstractClass('Zend_Db_Adapter_Abstract', array(), '', false);
     $this->_collection->setConnection($adapter);
     $this->assertInstanceOf('Zend_Db_Select', $this->_collection->getSelect());
     $clonedCollection = clone $this->_collection;
     $this->assertInstanceOf('Zend_Db_Select', $clonedCollection->getSelect());
     $this->assertNotSame($clonedCollection->getSelect(), $this->_collection->getSelect(), 'Collection was cloned but $this->_select in both initial and cloned collections reference the same object');
 }
开发者ID:natxetee,项目名称:magento2,代码行数:15,代码来源:DbTest.php


示例14: testClone

 /**
  * Test that after cloning collection $this->_select in initial and cloned collections
  * do not reference the same object
  *
  * @covers Varien_Data_Collection_Db::__clone
  */
 public function testClone()
 {
     $adapter = $this->_getAdapterMock('Zend_Db_Adapter_Pdo_Mysql', null, null);
     $this->_collection->setConnection($adapter);
     $this->assertInstanceOf('Zend_Db_Select', $this->_collection->getSelect());
     $clonedCollection = clone $this->_collection;
     $this->assertInstanceOf('Zend_Db_Select', $clonedCollection->getSelect());
     $this->assertNotSame($clonedCollection->getSelect(), $this->_collection->getSelect(), 'Collection was cloned but $this->_select in both initial and cloned collections reference the same object');
 }
开发者ID:nemphys,项目名称:magento2,代码行数:15,代码来源:DbTest.php


示例15: addGroupsCatalogFilterToCollection

 /**
  * Inner join the groupscatalog index table to hide entities not visible to the specified customer group id
  *
  * @param Varien_Data_Collection_Db $collection
  * @param int $groupId The customer group id
  * @return void
  */
 public function addGroupsCatalogFilterToCollection(Varien_Data_Collection_Db $collection, $groupId)
 {
     /* @var $helper Netzarbeiter_GroupsCatalog2_Helper_Data */
     $helper = Mage::helper('netzarbeiter_groupscatalog2');
     /**
      * This is slightly complicated but it works with products and
      * categories whether the flat tables enabled or not
      *
      * @var $entityType string
      * @var $entity Mage_Catalog_Model_Abstract
      */
     $entity = $collection->getNewEmptyItem();
     $entityType = $helper->getEntityTypeCodeFromEntity($entity);
     $this->_init($helper->getIndexTableByEntityType($entityType), 'id');
     if ($this->_doesIndexExists()) {
         $filterTable = $collection->getResource()->getTable($helper->getIndexTableByEntityType($entityType));
         $entityIdField = "{$this->_getCollectionTableAlias($collection)}.entity_id";
         $this->_addGroupsCatalogFilterToSelect($collection->getSelect(), $filterTable, $groupId, $collection->getStoreId(), $entityIdField);
     }
 }
开发者ID:aniljaiswal,项目名称:order-confirmation,代码行数:27,代码来源:Filter.php


示例16: __construct

 public function __construct()
 {
     parent::__construct(AO::getSingleton('core/resource')->getConnection('admin_read'));
     $this->_roleTable = AO::getSingleton('core/resource')->getTableName('admin/role');
     $this->_select->from($this->_roleTable);
     $this->setItemObjectClass(AO::getConfig()->getModelClassName('admin/acl_role'));
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:7,代码来源:Mysql4_Acl_Role_Collection.php


示例17: __construct

 public function __construct()
 {
     parent::__construct(Mage::getSingleton('core/resource')->getConnection('newsletter_read'));
     $this->_templateTable = Mage::getSingleton('core/resource')->getTableName('newsletter/template');
     $this->_select->from($this->_templateTable, array('template_id', 'template_code', 'template_type', 'template_subject', 'template_sender_name', 'template_sender_email', 'added_at', 'modified_at'));
     $this->setItemObjectClass(Mage::getConfig()->getModelClassName('newsletter/template'));
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:7,代码来源:Collection.php


示例18: __construct

 public function __construct()
 {
     parent::__construct(Mage::getSingleton('core/resource')->getConnection('directory_read'));
     $this->_countryTable = Mage::getSingleton('core/resource')->getTableName('directory/country');
     $this->_select->from(array('country' => $this->_countryTable));
     $this->setItemObjectClass(Mage::getConfig()->getModelClassName('directory/country'));
 }
开发者ID:HelioFreitas,项目名称:magento-pt_br,代码行数:7,代码来源:Collection.php


示例19: __construct

 public function __construct()
 {
     $resources = Mage::getSingleton('core/resource');
     parent::__construct($resources->getConnection('tag_read'));
     $this->_usersTable = $resources->getTableName('admin/user');
     $this->_roleTable = $resources->getTableName('admin/role');
     $this->_ruleTable = $resources->getTableName('admin/rule');
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:8,代码来源:Collection.php


示例20: __construct

 public function __construct()
 {
     $resources = Mage::getSingleton('core/resource');
     parent::__construct($resources->getConnection('livechat_read'));
     $this->_livechatTable = $resources->getTableName('livechat/livechat');
     $this->_select->from(array('livechat' => $this->_livechatTable), array('*'));
     $this->setItemObjectClass(Mage::getConfig()->getModelClassName('livechat/livechat'));
 }
开发者ID:macosxvn,项目名称:techheroes,代码行数:8,代码来源:Collection.php



注:本文中的Varien_Data_Collection_Db类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Varien_Data_Form类代码示例发布时间:2022-05-23
下一篇:
PHP Varien_Data_Collection类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap