Magento2: Admin dashboard Most Viewed Products Tab statistics not updating

Created on 10 Jan 2017  路  14Comments  路  Source: magento/magento2

Most Viewed Products tab records not being updating while visit to many products with guest user or even registered user.

notviewed

Fixed in 2.2.x Fixed in 2.3.x Clear Description Format is not valid Ready for Work bug report

All 14 comments

@technoquo thank you for your feedback.
Please, format this issue according to the Issue reporting guidelines: with steps to reproduce, actual result and expected result.
Please, also identify which version of Magento you are running.

Hi, Valoraven, sure I will explain follow with guidelines:

Title: Admin dashboard Most Viewed Products Tab statistics not updating

# Preconditions
Our version Magento CE 2.1.2
PHP 7.0

# Reproduce

  1. Enter login with user and password
  2. Dashboard
  3. Click Tab "Most Viewed Product" on Drashboard.

# Expected result:
Show most viewed product from customers.
# Actual result:
"We couldn't find any records."

notviewed

@technoquo thank you for your report.
We already have internal ticket for this issue: MAGETWO-46160

Hi @veloraven Where can I see the ticket MAGETWO-46160?

Thanks

Any news about MAGETWO-46160? Regards

Hi @veloraven, I also have the same issue in 2.1.3 CE.

Preconditions


  1. Composer upgrade Magento 2.1.2 CE --> 2.1.3 CE
  2. 2.
root@skynet:~# cat /proc/version
Linux version 3.16.0-4-amd64 ([email protected]) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.39-1 (2016-12-30)

3.

root@skynet:~# composer -V
Composer version 1.3.0 2016-12-24 00:47:03
    4.
root@skynet:~# dpkg -l | grep php7
rc  libapache2-mod-php7.0                7.0.14-1~dotdeb+8.1                  amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php7.0                               7.0.15-1~dotdeb+8.1                  all          server-side, HTML-embedded scripting language (metapackage)
ii  php7.0-bcmath                        7.0.15-1~dotdeb+8.1                  amd64        Bcmath module for PHP
ii  php7.0-cli                           7.0.15-1~dotdeb+8.1                  amd64        command-line interpreter for the PHP scripting language
ii  php7.0-common                        7.0.15-1~dotdeb+8.1                  amd64        documentation, examples and common module for PHP
ii  php7.0-curl                          7.0.15-1~dotdeb+8.1                  amd64        CURL module for PHP
ii  php7.0-dev                           7.0.15-1~dotdeb+8.1                  amd64        Files for PHP7.0 module development
ii  php7.0-fpm                           7.0.15-1~dotdeb+8.1                  amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php7.0-gd                            7.0.15-1~dotdeb+8.1                  amd64        GD module for PHP
ii  php7.0-igbinary                      2.0.1-1~dotdeb+8.1                   amd64        igbinary serializer for PHP
ii  php7.0-imagick                       3.4.2-1~dotdeb+8.2                   amd64        Provides a wrapper to the ImageMagick library
ii  php7.0-intl                          7.0.15-1~dotdeb+8.1                  amd64        Internationalisation module for PHP
ii  php7.0-json                          7.0.15-1~dotdeb+8.1                  amd64        JSON module for PHP
ii  php7.0-mbstring                      7.0.15-1~dotdeb+8.1                  amd64        MBSTRING module for PHP
ii  php7.0-mcrypt                        7.0.15-1~dotdeb+8.1                  amd64        libmcrypt module for PHP
ii  php7.0-mysql                         7.0.15-1~dotdeb+8.1                  amd64        MySQL module for PHP
ii  php7.0-opcache                       7.0.15-1~dotdeb+8.1                  amd64        Zend OpCache module for PHP
ii  php7.0-pspell                        7.0.15-1~dotdeb+8.1                  amd64        pspell module for PHP
ii  php7.0-readline                      7.0.15-1~dotdeb+8.1                  amd64        readline module for PHP
ii  php7.0-redis                         3.1.0-1~dotdeb+8.4                   amd64        PHP extension for interfacing with Redis
ii  php7.0-soap                          7.0.15-1~dotdeb+8.1                  amd64        SOAP module for PHP
ii  php7.0-xml                           7.0.15-1~dotdeb+8.1                  amd64        DOM, SimpleXML, WDDX, XML, and XSL module for PHP
ii  php7.0-xmlrpc                        7.0.15-1~dotdeb+8.1                  amd64        XMLRPC-EPI module for PHP
ii  php7.0-xsl                           7.0.15-1~dotdeb+8.1                  all          XSL module for PHP (dummy)
ii  php7.0-zip                           7.0.15-1~dotdeb+8.1                  amd64        Zip module for PHP

5.

root@skynet:~# dpkg -l | grep mariadb
ii  libmariadbclient18                   10.1.20+maria-1~jessie               amd64        MariaDB database client library
ii  mariadb-client                       10.1.20+maria-1~jessie               all          MariaDB database client (metapackage depending on the latest version)
ii  mariadb-client-10.1                  10.1.20+maria-1~jessie               amd64        MariaDB database client binaries
ii  mariadb-client-core-10.1             10.1.20+maria-1~jessie               amd64        MariaDB database core client binaries
ii  mariadb-common                       10.1.20+maria-1~jessie               all          MariaDB database common files (e.g. /etc/mysql/conf.d/mariadb.cnf)
ii  mariadb-server                       10.1.20+maria-1~jessie               all          MariaDB database server (metapackage depending on the latest version)
ii  mariadb-server-10.1                  10.1.20+maria-1~jessie               amd64        MariaDB database server binaries
ii  mariadb-server-core-10.1             10.1.20+maria-1~jessie               amd64        MariaDB database core server files

6.

root@skynet:~# dpkg -l | grep nginx
ii  libnginx-mod-http-auth-pam           1.10.2-2~dotdeb+8.2                  amd64        PAM authentication module for Nginx
ii  libnginx-mod-http-geoip              1.10.2-2~dotdeb+8.2                  amd64        GeoIP HTTP module for Nginx
ii  libnginx-mod-http-image-filter       1.10.2-2~dotdeb+8.2                  amd64        HTTP image filter module for Nginx
ii  libnginx-mod-http-lua                1.10.2-2~dotdeb+8.2                  amd64        LUA module for Nginx
ii  libnginx-mod-http-ndk                1.10.2-2~dotdeb+8.2                  amd64        Nginx Development Kit module
ii  libnginx-mod-http-perl               1.10.2-2~dotdeb+8.2                  amd64        Perl module for Nginx
ii  libnginx-mod-http-xslt-filter        1.10.2-2~dotdeb+8.2                  amd64        XSLT Transformation module for Nginx
ii  libnginx-mod-mail                    1.10.2-2~dotdeb+8.2                  amd64        Mail module for Nginx
ii  libnginx-mod-stream                  1.10.2-2~dotdeb+8.2                  amd64        Stream module for Nginx
ii  nginx-common                         1.10.2-2~dotdeb+8.2                  all          small, powerful, scalable web/proxy server - common files
ii  nginx-extras                         1.10.2-2~dotdeb+8.2                  amd64        nginx web/proxy server (extended version)

7.

root@skynet:~# dpkg -l | grep redis
ii  php5-redis                           2.2.5-1                              amd64        PHP extension for interfacing with Redis
ii  php7.0-redis                         3.1.0-1~dotdeb+8.4                   amd64        PHP extension for interfacing with Redis
ii  redis-server                         2:3.2.6-1~dotdeb+8.1                 amd64        Persistent key-value database with network interface
ii  redis-tools                          2:3.2.6-1~dotdeb+8.1                 amd64        Persistent key-value database with network interface (client)

Any news about MAGETWO-46160? Regards please need to fix my magento.

+1 for a fix date / update on this please. I need this feature for a M2 site I am currently developing. This issue was initially logged in August last year (https://github.com/magento/magento2/issues/6098) so any update on this would be greatly appreciated @veloraven . Thank you.

Seems to be the problem lays in query for a database. In class
"Magento\Reports\Model\ResourceModel\Product\Collection"

   public function addViewsCount($from = '', $to = '')
   {
    $eventTypes = $this->_eventTypeFactory->create()->getCollection();


    $eventTypes = $this->_eventTypeFactory->create()->getCollection();
    foreach ($eventTypes as $eventType) {
        if ($eventType->getEventName() == 'catalog_product_view') {
            $productViewEvent = (int)$eventType->getId();
            break;
        }
    }

    $this->getSelect()->reset()->from(
        ['report_table_views' => $this->getTable('report_event')],
        ['views' => 'COUNT(report_table_views.event_id)']
    )->join(
        ['e' => $this->getProductEntityTableName()],
        $this->getConnection()->quoteInto(
            'e.entity_id = report_table_views.object_id  AND e.attribute_set_id = ?',
            $this->getProductAttributeSetId()
        )
    )->where(
        'report_table_views.event_type_id = ?',
        $productViewEvent
    )->group(
        'e.entity_id'
    )->order(
        'views ' . self::SORT_ORDER_DESC
    )->having(
        'COUNT(report_table_views.event_id) > ?',
        0
    );

    if ($from != '' && $to != '') {
        $this->getSelect()->where('logged_at >= ?', $from)->where('logged_at <= ?', $to);
    }
    return $this;
   }`

method $this->getProductAttributeSetId() return 4
and we have sql query like this

SELECT COUNT(report_table_views.event_id) ASviews,e.* FROMreport_eventASreport_table_views INNER JOINcatalog_product_entityASeON e.entity_id = report_table_views.object_id AND e.attribute_set_id = '4' WHERE (report_table_views.event_type_id = 1) GROUP BYe.entity_idHAVING (COUNT(report_table_views.event_id) > 0) ORDER BYviewsDESC

this means that it shows products that related only to default attribute set.
So to solve this issue we need to remove condition where we check the Attribute Set.

i using Magento 2.1.6 version. i have faced same problem in my admin dashboard.

@technoquo, thank you for your report.
The issue is already fixed in develop branch, 2.2.0

Hi,
This problem doesn't fix. We use magento 2.2.1 but we still have this issue.

Using magento 2.3.4 . the statistics are pretty much the same since the first install

Hi,
I have same issue. We use magento 2.3.4
image

Was this page helpful?
0 / 5 - 0 ratings