Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customer review report search Bug in 2.1.x, 2.2 #10301

Closed
mageprince opened this issue Jul 21, 2017 · 14 comments
Closed

Customer review report search Bug in 2.1.x, 2.2 #10301

mageprince opened this issue Jul 21, 2017 · 14 comments
Assignees
Labels
bug report Component: Customer Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@mageprince
Copy link
Contributor

mageprince commented Jul 21, 2017

Preconditions

  1. Magento 2.1.5,2.1.6,2.1.7
  2. PHP 7.0.17

Steps to reproduce

  1. Go to Reports -> By Customers
  2. Enter customer name in search box
  3. Click on serach

Expected result

  1. Retrive customer result

Actual result

  1. Fatal Error: Column not found: 1054 Unknown column 'customer_name' in 'where clause', query was: SELECT COUNT(DISTINCT detail.customer_id) FROM review AS main_table
@mageprince mageprince changed the title Customer review report search not working in 2.1.7 Customer review report search not working in 2.1.5, 2.1.6, 2.1.7 Jul 21, 2017
@vishveskrish
Copy link

Hey @Prince108 ,

We are facing same issue ! let us know if you found any patch.

Thanks,
Vishves Shah

@dev-Dhaval
Copy link

Its solved

need to update two files

  1. Update _joinCustomers function in
    vendor/magento/module-reports/Model/ResourceModel/Review/Customer/Collection.php
protected function _joinCustomers()
    {
	
        /** @var $connection \Magento\Framework\DB\Adapter\AdapterInterface */
        $connection = $this->getConnection();
        //Prepare fullname field result
        $customerFullname = $connection->getConcatSql(['customer.firstname'], ' ');
        $this->getSelect()->reset(
            \Magento\Framework\DB\Select::COLUMNS
        )->joinInner(
            ['customer' => $connection->getTableName('customer_entity')],
            'customer.entity_id = detail.customer_id',
            []
        )->columns(
            [
                'customer_id' => 'detail.customer_id',
                'firstname' => $customerFullname,
                'review_cnt' => 'COUNT(main_table.review_id)',
            ]
        )->group(
            'detail.customer_id'
        );
	//echo $this->getSelect()->__toString();;exit;
        return $this;
    }
  1. Update line no 43 to 53 in below file
    vendor/magento/module-reports/view/adminhtml/layout/reports_report_review_customer_grid.xml
<block class="Magento\Backend\Block\Widget\Grid\Column" as="firstname">
                        <arguments>
                            <argument name="header" xsi:type="string" translate="true">Customer</argument>
                            <argument name="index" xsi:type="string">firstname</argument>
                            <argument name="type" xsi:type="string">text</argument>
                            <argument name="id" xsi:type="string">firstname</argument>
                            <argument name="default" xsi:type="string" translate="true">Guest</argument>
                            <argument name="column_css_class" xsi:type="string">col-name</argument>
                            <argument name="header_css_class" xsi:type="string">col-name</argument>
                        </arguments>
                    </block>

@mageprince
Copy link
Contributor Author

@dev-Dhaval thanks for your reply. But this will not work. I have debugged code and found the issue.
If you see below query by printing $this->_joinCustomers() values.

SELECT detail.customer_id, CONCAT_WS(' ', customer.firstname, customer.lastname) AS customer_name, COUNT(main_table.review_id) AS review_cntFROMbn0z_reviewASmain_tableINNER JOINbn0z_review_detailASdetailON main_table.review_id = detail.review_id INNER JOINbn0z_customer_entityAScustomerON customer.entity_id = detail.customer_id GROUP BYdetail.customer_id``

Case 1 : each column assigns by the alias like 'customer_name`, 'review_cnt', ... that's fine. But when we search on grid It is taking wrong data.
You can debug and share your thoughts on it.
@vishveskrish: We are waiting for the response from Magento team.

@dev-Dhaval
Copy link

dev-Dhaval commented Jul 22, 2017

@Prince108 , your query look like coming from cache. because in our updated code have not use customer.lastname and its showing in your query. can you please apply setup :upgrade command . because it's working from my side or compare _joinCustomers with our updated code
Thanks

@mageprince
Copy link
Contributor Author

mageprince commented Jul 22, 2017

@dev-Dhaval, I print this query in default Magento collection.php without changes.
In your code, you just change alias name and assign this name in grid xml. It's doesn't matter filed has value or not.

what I am trying to say that $this->_joinCustomers() returns right query.
I also try to run this query directly in phpmyadmin it's working fine. but at the time of search customer grid get columns (customer_name and review_cnt) from directly in tables without including this join query.

You can debug and share your thoughts on it.
We are waiting for the response from Magento team.

@mageprince mageprince changed the title Customer review report search not working in 2.1.5, 2.1.6, 2.1.7 Customer review report search Bug in 2.1.5, 2.1.6, 2.1.7 Jul 22, 2017
@RomanKrut
Copy link

@Prince108 Hi. Thanks for your feedback. The internal ticket MAGETWO-70955 was created to address this issue.

@veloraven veloraven added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jul 24, 2017
@mageprince mageprince changed the title Customer review report search Bug in 2.1.5, 2.1.6, 2.1.7 Customer review report search Bug in 2.1.x Aug 21, 2017
@mageprince
Copy link
Contributor Author

@veloraven

This issue still continues in Magento 2.1.8 and Magento 2.2 also in Magento 2.2 EE. I have developed simple module to overcome this issue. If you need I can share with you.

Thank You
Prince Patel

@mageprince mageprince changed the title Customer review report search Bug in 2.1.x Customer review report search Bug in 2.1.x, 2.2 Aug 25, 2017
@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Component: Customer Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team magento-engcom-team added Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Sep 27, 2017
@magento-engcom-team magento-engcom-team removed Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line labels Sep 28, 2017
@magento-engcom-team
Copy link
Contributor

@mageprince, thank you for your report.
We've created internal ticket(s) MAGETWO-70955 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed labels Sep 28, 2017
@osrecio
Copy link
Member

osrecio commented Oct 5, 2017

Assign to me

@osrecio
Copy link
Member

osrecio commented Oct 17, 2017

Created PR's and BackPorts

@okorshenko
Copy link
Contributor

The issue has been fixed in 2.2-develop branch.

@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-82179

@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-82176

@magento-team
Copy link
Contributor

Internal ticket to track issue progress: MAGETWO-82178

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Customer Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

9 participants