Note that there are some explanatory texts on larger screens.

plurals
  1. POProduct collection filtering/order direction issue
    primarykey
    data
    text
    <p>For my category view. I have a select drop down which uses ajax to set a session with the option value. </p> <p>I have overridden <code>Mage_Catalog_Block_Product_List</code>.</p> <p>This session value processed from ajax is called in the '<code>protected function _getProductCollection()</code>' override to filter the product collection as needed. </p> <p>My first problem is that I would like to filter by an attribute, based on three values on these attributes:</p> <pre><code> $collection = parent::_getProductCollection(); $collection -&gt;addAttributeToFilter('name', array('in' =&gt; array('Cat','Adam', 'Paul'))); $collection-&gt;addAttributeToSort('name = Cat', 'DESC'); $collection-&gt;addAttributeToSort('name = Adam', 'DESC'); $collection-&gt;addAttributeToSort('name = Paul', 'DESC'); return $this-&gt;_productCollection; </code></pre> <p>The problem is that I want to position these as needed. For example I need Cat first then Adam then Paul. Is there any way to position these?</p> <p>The second issue is that I need position an '<code>sort by</code>' option. '<code>asc</code>' is the default, however what I need it for descending to be default. </p> <p>So far I have overridden <code>'Mage_Catalog_Block_Product_List_Toolbar'</code> and used this code:</p> <pre><code>protected $_direction = 'desc'; </code></pre> <p>This however is not changing the direction. </p> <p>Will the sort by take precedence over the custom product collection I have created?</p> <p>LOG</p> <p>a:5:{i:0;s:126:"SQLSTATE[42000]: Syntax error or access violation: 1582 Incorrect parameter count in the call to native function 'FIND_IN_SET'";i:1;s:6707:"#0 /var/www/vhosts/mydomain.com/httpdocs/mypath/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array) /var/www/vhosts/mydomain.com/httpdocs/mypath/lib/Zend/Db/Statement.php(300): Varien_Db_Statement_Pdo_Mysql->_execute(Array) /var/www/vhosts/mydomain.com/httpdocs/mypath/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array) /var/www/vhosts/mydomain.com/httpdocs/mypath/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT COUNT(DI...', Array) /var/www/vhosts/mydomain.com/httpdocs/mypath/lib/Varien/Db/Adapter/Pdo/Mysql.php(419): Zend_Db_Adapter_Pdo_Abstract->query('SELECT COUNT(DI...', Array) /var/www/vhosts/mydomain.com/httpdocs/mypath/lib/Zend/Db/Adapter/Abstract.php(825): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array) /var/www/vhosts/mydomain.com/httpdocs/mypath/lib/Varien/Data/Collection/Db.php(225): Zend_Db_Adapter_Abstract->fetchOne(Object(Varien_Db_Select), Array) /var/www/vhosts/mydomain.com/httpdocs/mypath/lib/Varien/Data/Collection.php(225): Varien_Data_Collection_Db->getSize() /var/www/vhosts/mydomain.com/httpdocs/mypath/lib/Varien/Data/Collection.php(211): Varien_Data_Collection->getLastPageNumber() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(1036): Varien_Data_Collection->getCurPage() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php(871): Mage_Eav_Model_Entity_Collection_Abstract->_loadEntities(false, false) /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Review/Model/Observer.php(78): Mage_Eav_Model_Entity_Collection_Abstract->load() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Model/App.php(1334): Mage_Review_Model_Observer->catalogBlockProductCollectionBeforeToHtml(Object(Varien_Event_Observer)) /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Model/App.php(1307): Mage_Core_Model_App->_callObserverMethod(Object(Mage_Review_Model_Observer), 'catalogBlockPro...', Object(Varien_Event_Observer)) /var/www/vhosts/mydomain.com/httpdocs/mypath/app/Mage.php(447): Mage_Core_Model_App->dispatchEvent('catalog_block_p...', Array) /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Catalog/Block/Product/List.php(163): Mage::dispatchEvent('catalog_block_p...', Array) /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Abstract.php(862): Mage_Catalog_Block_Product_List->_beforeToHtml() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('product_list', true) /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Catalog/Block/Category/View.php(85): Mage_Core_Block_Abstract->getChildHtml('product_list') /var/www/vhosts/mydomain.com/httpdocs/mypath/app/design/frontend/default/gomer/template/catalog/category/view.phtml(115): Mage_Catalog_Block_Category_View->getProductListHtml() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/vhosts...') /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/defaul...') /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Text_List->_toHtml() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Abstract.php(582): Mage_Core_Block_Abstract->toHtml() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Abstract.php(526): Mage_Core_Block_Abstract->_getChildHtml('content', true) /var/www/vhosts/mydomain.com/httpdocs/mypath/app/design/frontend/default/gomer/template/page/2columns-left.phtml(49): Mage_Core_Block_Abstract->getChildHtml('content') /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/vhosts...') /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/defaul...') /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Block/Abstract.php(863): Mage_Core_Block_Template->_toHtml() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Catalog/controllers/CategoryController.php(159): Mage_Core_Controller_Varien_Action->renderLayout() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Controller/Varien/Action.php(419): Mage_Catalog_CategoryController->viewAction() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('view') /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Controller/Varien/Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) /var/www/vhosts/mydomain.com/httpdocs/mypath/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch() /var/www/vhosts/mydomain.com/httpdocs/mypath/app/Mage.php(683): Mage_Core_Model_App->run(Array) /var/www/vhosts/mydomain.com/httpdocs/mypath/index.php(87): Mage::run('', 'store') {main}";s:3:"url";s:72:"/mypath/index.php/books-for-adults/autobiography-and-biography.html";s:11:"script_name";s:22:"/mypath/index.php";s:4:"skin";s:7:"english";}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload