本文整理汇总了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.');
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}