Note that there are some explanatory texts on larger screens.

plurals
  1. POcustomer group sorting return error in magento admin panel
    primarykey
    data
    text
    <p>In our magento admin panel, we used the <code>group</code> column to sort the customers.</p> <p>But it displays query with errors.</p> <p>That means when click on the <code>group</code> column it goes to magento admin <code>dashboard</code>.</p> <p>So we clicked again in Manage Customers Link but it now displays error with query.</p> <p>The following is the query with errors:</p> <pre><code>SELECT `e`.*, `at_prefix`.`value` AS `prefix`, `at_firstname`.`value` AS `firstname`, `at_middlename`.`value` AS `middlename`, `at_lastname`.`value` AS `lastname`, `at_suffix`.`value` AS `suffix`, CONCAT(IF(at_prefix.value IS NOT NULL AND at_prefix.value != '', CONCAT(LTRIM(RTRIM(at_prefix.value)), ' '), ''), LTRIM(RTRIM(at_firstname.value)), ' ', IF(at_middlename.value IS NOT NULL AND at_middlename.value != '', CONCAT(LTRIM(RTRIM(at_middlename.value)), ' '), ''), LTRIM(RTRIM(at_lastname.value)), IF(at_suffix.value IS NOT NULL AND at_suffix.value != '', CONCAT(' ', LTRIM(RTRIM(at_suffix.value))), '')) AS `name`, `at_default_billing`.`value` AS `default_billing`, `at_billing_postcode`.`value` AS `billing_postcode`, `at_billing_city`.`value` AS `billing_city`, `at_billing_telephone`.`value` AS `billing_telephone`, `at_billing_region`.`value` AS `billing_region`, `at_billing_country_id`.`value` AS `billing_country_id`, `at_group_id`.`value` AS `group_id` FROM `customer_entity` AS `e` LEFT JOIN `customer_entity_varchar` AS `at_prefix` ON (`at_prefix`.`entity_id` = `e`.`entity_id`) AND (`at_prefix`.`attribute_id` = '4') LEFT JOIN `customer_entity_varchar` AS `at_firstname` ON (`at_firstname`.`entity_id` = `e`.`entity_id`) AND (`at_firstname`.`attribute_id` = '5') LEFT JOIN `customer_entity_varchar` AS `at_middlename` ON (`at_middlename`.`entity_id` = `e`.`entity_id`) AND (`at_middlename`.`attribute_id` = '6') LEFT JOIN `customer_entity_varchar` AS `at_lastname` ON (`at_lastname`.`entity_id` = `e`.`entity_id`) AND (`at_lastname`.`attribute_id` = '7') LEFT JOIN `customer_entity_varchar` AS `at_suffix` ON (`at_suffix`.`entity_id` = `e`.`entity_id`) AND (`at_suffix`.`attribute_id` = '8') LEFT JOIN `customer_entity_int` AS `at_default_billing` ON (`at_default_billing`.`entity_id` = `e`.`entity_id`) AND (`at_default_billing`.`attribute_id` = '13') LEFT JOIN `customer_address_entity_varchar` AS `at_billing_postcode` ON (`at_billing_postcode`.`entity_id` = `at_default_billing`.`value`) AND (`at_billing_postcode`.`attribute_id` = '30') LEFT JOIN `customer_address_entity_varchar` AS `at_billing_city` ON (`at_billing_city`.`entity_id` = `at_default_billing`.`value`) AND (`at_billing_city`.`attribute_id` = '26') LEFT JOIN `customer_address_entity_varchar` AS `at_billing_telephone` ON (`at_billing_telephone`.`entity_id` = `at_default_billing`.`value`) AND (`at_billing_telephone`.`attribute_id` = '31') LEFT JOIN `customer_address_entity_varchar` AS `at_billing_region` ON (`at_billing_region`.`entity_id` = `at_default_billing`.`value`) AND (`at_billing_region`.`attribute_id` = '28') LEFT JOIN `customer_address_entity_varchar` AS `at_billing_country_id` ON (`at_billing_country_id`.`entity_id` = `at_default_billing`.`value`) AND (`at_billing_country_id`.`attribute_id` = '27') LEFT JOIN `customer_entity_varchar` AS `at_group_id` ON (`at_group_id`.`entity_id` = `e`.`entity_id`) AND (`at_group_id`.`attribute_id` = '10') WHERE (`e`.`entity_type_id` = '1') ORDER BY `group_id` ASC LIMIT 20 </code></pre> <p>When we excuting this query phpmyadmin->SQL it return error as:</p> <pre><code>#1052 - Column 'group_id' in order clause is ambiguous </code></pre> <p>So how can i solve this?</p> <p>if there is any problem with my admin panel?</p> <p><strong>UPDATE</strong></p> <p>This is the function we added in </p> <p><code>D:\wamp\www\mysite\app\code\core\Mage\Adminhtml\Block\Customer\Grid.php</code> :</p> <pre><code>protected function _groupFilter($collection, $column){ $this-&gt;getCollection()-&gt;getSelect()-&gt;where(new Zend_Db_Expr("{$this-&gt;getColumn()-&gt;getFilterIndex()} like '{$column-&gt;getFilter()-&gt;getValue()}'")); return $this; } protected function _prepareCollection() { $collection = Mage::getResourceModel('customer/customer_collection') -&gt;addNameToSelect() -&gt;addAttributeToSelect('email') -&gt;addAttributeToSelect('created_at') -&gt;addAttributeToSelect('group_id') -&gt;joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left') -&gt;joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left') -&gt;joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left') -&gt;joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left') -&gt;joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left'); $this-&gt;setCollection($collection); return parent::_prepareCollection(); } </code></pre> <p>Amd this the column in <code>_prepareColumns()</code> ;</p> <pre><code> $this-&gt;addColumn('group', array( 'header' =&gt; Mage::helper('customer')-&gt;__('Group'), 'width' =&gt; '100', 'index' =&gt; 'group_id', 'type' =&gt; 'options', 'filter_index' =&gt; 'e.group_id', 'filter_condition_callback' =&gt; array($this, '_groupFilter'), 'options' =&gt; $groups, )); </code></pre> <p>Then i got this error:</p> <p>Fatal error: Call to a member function getFilterIndex() on a non-object in <code>D:\wamp\www\mysite\app\code\core\Mage\Adminhtml\Block\Customer\Grid.php on line 65</code></p> <p>This is the error in log file:</p> <pre><code>2013-08-30T06:48:26+00:00 ERR (3): Warning: Missing argument 1 for Mage_Adminhtml_Block_Widget_Grid::getColumn(), called in D:\wamp\www\mysite\app\code\core\Mage\Adminhtml\Block\Customer\Grid.php on line 65 and defined in D:\wamp\www\mysite\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php on line 431 2013-08-30T06:48:26+00:00 ERR (3): Notice: Undefined variable: columnId in D:\wamp\www\mysite\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php on line 433 </code></pre>
    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