当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Catalog_Model_Resource_Product_Collection::setOrder方法代码示例

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


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

示例1: testSetOrder

 /**
  * @dataProvider setOrderDataProvider
  */
 public function testSetOrder($order, $expectedOrder)
 {
     $this->_collection->setOrder($order);
     $this->_collection->load();
     // perform real SQL query
     $selectOrder = $this->_collection->getSelect()->getPart(Zend_Db_Select::ORDER);
     foreach ($expectedOrder as $field) {
         $orderBy = array_shift($selectOrder);
         $this->assertArrayHasKey(0, $orderBy);
         $this->assertTrue(false !== strpos($orderBy[0], $field), 'Ordering by same column more than once is restricted by multiple RDBMS requirements.');
     }
 }
开发者ID:natxetee,项目名称:magento2,代码行数:15,代码来源:CollectionTest.php

示例2: setOrder

 /**
  * Set Order field
  *
  * @param string $attribute
  * @param string $dir
  * @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection
  */
 public function setOrder($attribute, $dir = 'desc')
 {
     if ($attribute == 'relevance') {
         //$this->getSelect()->order("relevance {$dir}");
     } else {
         parent::setOrder($attribute, $dir);
     }
     return $this;
 }
开发者ID:axovel,项目名称:easycarcare,代码行数:16,代码来源:Collection.php

示例3: setOrder

 /**
  * Add sorting
  *
  * @param string $attribute
  * @param string $dir
  * @return Mage_Reports_Model_Resource_Product_Downloads_Collection
  */
 public function setOrder($attribute, $dir = self::SORT_ORDER_DESC)
 {
     if ($attribute == 'purchases' || $attribute == 'downloads' || $attribute == 'link_title') {
         $this->getSelect()->order($attribute . ' ' . $dir);
     } else {
         parent::setOrder($attribute, $dir);
     }
     return $this;
 }
开发者ID:par-orillonsoft,项目名称:magento_work,代码行数:16,代码来源:Collection.php

示例4: setOrder

 /**
  * Set Order field
  *
  * @param string $attribute
  * @param string $dir
  * @return Mage_CatalogSearch_Model_Resource_Fulltext_Collection
  */
 public function setOrder($attribute, $dir = 'desc')
 {
     if (!$this->checkSearchaniseResult()) {
         return parent::setOrder($attribute, $dir);
     }
     if ($attribute == 'relevance') {
         $product_ids = $this->getSearchaniseRequest()->getProductIdsString();
         if (!empty($product_ids)) {
             $this->getSelect()->order("FIELD (e.entity_id, {$product_ids}) {$dir}");
         }
     } else {
         parent::setOrder($attribute, $dir);
     }
     return $this;
 }
开发者ID:xiaoguizhidao,项目名称:ecommerce,代码行数:22,代码来源:Collection.php

示例5: setOrder

 /**
  * Set order to attribute
  *
  * @param string $attribute
  * @param string $dir
  * @return Mage_Review_Model_Resource_Review_Product_Collection
  */
 public function setOrder($attribute, $dir = 'DESC')
 {
     switch ($attribute) {
         case 'rt.review_id':
         case 'rt.created_at':
         case 'rt.status_id':
         case 'rdt.title':
         case 'rdt.nickname':
         case 'rdt.detail':
             $this->getSelect()->order($attribute . ' ' . $dir);
             break;
         case 'stores':
             // No way to sort
             break;
         case 'type':
             $this->getSelect()->order('rdt.customer_id ' . $dir);
             break;
         default:
             parent::setOrder($attribute, $dir);
     }
     return $this;
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:29,代码来源:Collection.php

示例6: setOrder

 /**
  * Set order
  *
  * @param string $attribute
  * @param string $dir
  * @return Mage_Reports_Model_Resource_Product_Collection
  */
 public function setOrder($attribute, $dir = self::SORT_ORDER_DESC)
 {
     if (in_array($attribute, array('carts', 'orders', 'ordered_qty'))) {
         $this->getSelect()->order($attribute . ' ' . $dir);
     } else {
         parent::setOrder($attribute, $dir);
     }
     return $this;
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:16,代码来源:Collection.php

示例7: setOrder

 /**
  * Set sorting order
  *
  * $attribute can also be an array of attributes
  *
  * @param string|array $attribute
  * @param string $dir
  * @return Mage_Catalog_Model_Resource_Product_Link_Product_Collection
  */
 public function setOrder($attribute, $dir = self::SORT_ORDER_ASC)
 {
     if ($attribute == 'position') {
         return $this->setPositionOrder($dir);
     } elseif ($attribute == 'attribute_set_id') {
         return $this->setAttributeSetIdOrder($dir);
     }
     return parent::setOrder($attribute, $dir);
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:18,代码来源:Collection.php

示例8: setOrder

 /**
  * Set attribute order
  *
  * @param string $attribute
  * @param string $dir
  * @return Mage_Tag_Model_Resource_Product_Collection
  */
 public function setOrder($attribute, $dir = 'desc')
 {
     if ($attribute == 'popularity') {
         $this->getSelect()->order($attribute . ' ' . $dir);
     } else {
         parent::setOrder($attribute, $dir);
     }
     return $this;
 }
开发者ID:cnglobal-sl,项目名称:caterez,代码行数:16,代码来源:Collection.php

示例9: setOrder

 /**
  * Set Order field
  *
  * @param string $attribute
  * @param string $dir
  * @return Mage_Catalog_Model_Resource_Product_Collection
  */
 public function setOrder($attribute, $dir = parent::SORT_ORDER_ASC)
 {
     //         $helper=Mage::helper('autocompleteplus_autosuggest');
     //         $enabledFulltext = $helper->getConfigDataByFullPath('autocompleteplus/config/enabled_fulltext');
     if ($this->is_fulltext_enabled && $attribute == 'relevance') {
         $dir = parent::SORT_ORDER_ASC;
         $id_str = count($this->list_ids) > 0 ? implode(',', $this->list_ids) : '0';
         if (!empty($id_str)) {
             $sort = "FIELD(e.entity_id, {$id_str}) {$dir}";
             $this->getSelect()->order(new Zend_Db_Expr($sort));
         }
     } else {
         return parent::setOrder($attribute, $dir);
     }
     return $this;
 }
开发者ID:xiaoguizhidao,项目名称:mydigibits,代码行数:23,代码来源:Collection.php

示例10: setOrderParent

 /**
  * Set Order field
  *
  * @param string $attribute
  * @param string $dir
  * @return Mage_CatalogSearch_Model_Mysql4_Fulltext_Collection
  */
 public function setOrderParent($attribute, $dir = 'desc')
 {
     return parent::setOrder($attribute, $dir);
 }
开发者ID:kozinthetdbp,项目名称:shopmyar,代码行数:11,代码来源:Collection.php


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