當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Varien_Data_Collection::getResource方法代碼示例

本文整理匯總了PHP中Varien_Data_Collection::getResource方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Data_Collection::getResource方法的具體用法?PHP Varien_Data_Collection::getResource怎麽用?PHP Varien_Data_Collection::getResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Varien_Data_Collection的用法示例。


在下文中一共展示了Varien_Data_Collection::getResource方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setCollection

 /**
  * set collection object
  *
  * @param Varien_Data_Collection $collection
  */
 public function setCollection($collection)
 {
     if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
         $select = $collection->getSelect();
         $fromParts = $select->getPart(Zend_Db_Select::FROM);
         if (isset($fromParts['at_qty'])) {
             unset($fromParts['at_qty']);
             $select->reset(Zend_Db_Select::FROM);
             $select->setPart(Zend_Db_Select::FROM, $fromParts);
             $subquery = $collection->getConnection()->select()->from(array('at_sub_qty' => $collection->getResource()->getTable('cataloginventory/stock_item')), array('product_id'))->columns(new Zend_Db_Expr("SUM(at_sub_qty.qty) AS qty"))->group('at_sub_qty.product_id');
             $select->joinLeft(array('at_qty' => $subquery), 'at_qty.product_id=e.entity_id', array());
         }
     }
     parent::setCollection($collection);
 }
開發者ID:Rugento,項目名稱:ADM_Warehouse,代碼行數:20,代碼來源:Grid.php

示例2: setCollection

 /**
  * Set collection to pager
  *
  * @param Varien_Data_Collection $collection
  * @return Mage_Catalog_Block_Product_List_Toolbar
  */
 public function setCollection($collection)
 {
     $this->_collection = $collection;
     $this->_collection->setCurPage($this->getCurrentPage());
     // we need to set pagination only if passed value integer and more that 0
     $limit = (int) $this->getLimit();
     if ($limit) {
         $this->_collection->setPageSize($limit);
     }
     if ($this->getCurrentOrder() && $this->getRequest()->getParam('order')) {
         if ($this->getCurrentOrder() == 'new' && Mage::registry('current_category')) {
             $this->_collection->setOrder('entity_id', 'desc');
         } else {
             if ($this->getCurrentOrder() == 'popular' && Mage::registry('current_category')) {
                 $this->getCollection()->getSelect()->joinLeft(array('sfoi' => $collection->getResource()->getTable('sales/order_item')), 'e.entity_id = sfoi.product_id', array('qty_ordered' => 'SUM(sfoi.qty_ordered)'))->group('e.entity_id')->order('qty_ordered ' . $this->getCurrentDirection());
             } else {
                 if ($this->getCurrentOrder() == 'price' && Mage::registry('current_category')) {
                     $this->_collection->setOrder($this->getCurrentOrder(), $this->getCurrentDirection());
                 } else {
                     $this->_collection->setOrder('position', 'asc');
                 }
             }
         }
     } else {
         if (Mage::registry('current_category')) {
             $this->_collection->setOrder('position', 'asc');
         }
     }
     return $this;
 }
開發者ID:sshegde123,項目名稱:wmp8,代碼行數:36,代碼來源:Toolbar.php


注:本文中的Varien_Data_Collection::getResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。