Jump to content

PS 8 - Activity overview stopped working, error 500


nestor44

Recommended Posts

 

Hello, I have a little problem with Activity overview in the Dashboard. It does not showing me any data. All I have are the arrows just like in the screenshot below.

screenshop.jpg.b5f92ed2b139125e3950b5009bdb561f.jpg

I have installed a fresh PS 8.0.1 and it was working with no problem. The Activity overview stopped working either after upgrade from PS 8.0.1 to 8.0.2 or after upgrade from PS 8.0.2 to 8.0.3. Unfortunately, I have not noticed when this happened exactly. I have not upgraded to 8.0.4 yet. When I click on Olnine Visitors in the Activity overview I have Error 500 array_map(): Argument #2 ($array) must be of type array, bool given. 

in controllers/admin/AdminStatsTabController.php (line 179)
    protected function getModules()    {        return array_map(            function ($moduleArray) {return ['name' => $moduleArray['module']]; },            Hook::getHookModuleExecList('displayAdminStatsModules')        );    }    public function displayStats()    {

In the logs tab I have a following problems:

 

CRITICAL
18:18:14
request	Uncaught PHP Exception TypeError: "array_map(): Argument #2 ($array) must be of type array, bool given" at /XXXXX/controllers/admin/AdminStatsTabController.php line 179
{
    "exception": {}
}
DEBUG
18:18:12
php	Warning: filemtime(): stat failed for /XXXX/admin828entgy6vamtjzorju/themes//template
{
    "exception": {
        "severity": 2,
        "file": "/XXXX/classes/controller/AdminController.php",
        "line": 462,
        "trace": [
            {
                "file": "/XXXXX/classes/controller/Controller.php",
                "line": 246,
                "function": "__construct",
                "class": "AdminControllerCore",
                "type": "->"
            }
        ],
        "count": 1
    }
}

 

 

I have attached screenshots of entire Debug. I have no iea what happened and how to fix this. Does anyone know how to solve?

debug1.jpg

debug2.jpg

debug3.jpg

 

Edited by banan_44 (see edit history)
Link to comment
Share on other sites

9 hours ago, ComGrafPL said:

Have you tried to reset / reinstall dashboard modules?

Thank you for your reply. I have reset Dashboard Activity module but that did not help. I think the problem with dashboard activity comes from the modules that is responsible for showing the current Online Visitors. The error 500 only appears when I click on Online Visitors. Rest sections of Dashboard Activity are clickble and show no error 500. Only Online Visitors shows error 500. I do not know which module is responsible for Online Visitors.

Link to comment
Share on other sites

7 minutes ago, banan_44 said:

Thank you for your reply. I have reset Dashboard Activity module but that did not help. I think the problem with dashboard activity comes from the modules that is responsible for showing the current Online Visitors. The error 500 only appears when I click on Online Visitors. Rest sections of Dashboard Activity are clickble and show no error 500. Only Online Visitors shows error 500. I do not know which module is responsible for Online Visitors.

Maybe this will help you out. Source data of statistic and other solutions:

 

  • Like 1
Link to comment
Share on other sites

24 minutes ago, ComGrafPL said:

Maybe this will help you out. Source data of statistic and other solutions:

 

Thank you for this link. The problem is solved. Your link gave me a little hint on which modules I should focus on. It was mentioned to check Google Analytics modules. It turns out that Google Analytics changed the Google Analytics Tracking ID. I hae enebled Google Analytics 4 some time ago but I was not aware that the Tracking ID has changed and GA4 has different ID. I was still using the old UA tracking ID. After inserting the GA4 tracking ID the Dashboard Activity started to work again. But now it show incorrect information regarding New Messages (all messages are read and closed), Product reviews (I have somthing over 300 reviews) and out of stock products (I have a little over 1000 out of stock products). Is there a way to clean up these data to show correct numbers?

 

image.png.edd0396facb15d5d3cadb0ed0f65388f.png

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

I have now three shops with the version 8.0.4. The activity overview works on none of them. One of them is a new clean prestashop installation.

I tried every solution for older shops I could find. I think, it has to be a generell problem with prestashop 8. Has anyone found a solution?

Link to comment
Share on other sites

  • 3 weeks later...
  • 2 years later...
Quote

When upgrading to PrestaShop 9, many merchants encounter the error “SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id_shop' in WHERE is ambiguous” in the dashactivity module. This happens because several tables (orders, cart, customer, connections, etc.) contain an id_shop column, and the default queries in the module do not always qualify the column with a table alias. The fix is straightforward: open modules/dashactivity/dashactivity.php and update each SQL statement to give the main table an alias (for example o for orders, c for connections, ca for cart) and then pass that alias into Shop::addSqlRestriction(...). This ensures that every condition reads o.id_shop or ca.id_shop instead of the ambiguous id_shop. After patching and clearing cache, the dashboard KPIs load correctly without SQL errors. This small but critical adjustment improves compatibility with PrestaShop 9’s stricter SQL parsing and helps developers maintain multishop-ready code.
Below are exact patches you can apply to your file (modules/dashactivity/dashactivity.php) — only the changed lines shown.

1) Visits / unique visitors (first query)

Before

FROM `' . _DB_PREFIX_ . 'connections` ... ' . Shop::addSqlRestriction(false)

After

FROM `' . _DB_PREFIX_ . 'connections` c0 ... ' . Shop::addSqlRestriction(false, 'c0')

2) Online visitor list (already OK)

You already have:

FROM `' . _DB_PREFIX_ . 'connections` c ... ' . Shop::addSqlRestriction(false, 'c') . '

No change needed.

3) Pending orders

Before

FROM `' . _DB_PREFIX_ . 'orders` o ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER)

After

FROM `' . _DB_PREFIX_ . 'orders` o ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o')

4) Abandoned cart

Before

FROM `' . _DB_PREFIX_ . 'cart` ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER)

After

FROM `' . _DB_PREFIX_ . 'cart` ca ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'ca')

5) Returns / exchanges (already OK)

You already pass 'o':

' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'o')

6) Active shopping carts

Before

FROM `' . _DB_PREFIX_ . 'cart` ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER)

After

FROM `' . _DB_PREFIX_ . 'cart` ca2 ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'ca2')

7) New customers

Before

FROM `' . _DB_PREFIX_ . 'customer` ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER)

After

FROM `' . _DB_PREFIX_ . 'customer` c1 ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'c1')

8) New registrations

Before

FROM `' . _DB_PREFIX_ . 'customer` ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER)

After

FROM `' . _DB_PREFIX_ . 'customer` c2 ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'c2')

9) Total subscribers

Before

FROM `' . _DB_PREFIX_ . 'customer` ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER)

After

FROM `' . _DB_PREFIX_ . 'customer` c3 ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'c3')

10) Product reviews

You already have Shop::addSqlAssociation('product','p'). That creates a shop alias named product_shop. If you leave the extra restriction in place, target the shop alias:

Before

... ' . Shop::addSqlAssociation('product', 'p') . ' ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER)

After

... ' . Shop::addSqlAssociation('product', 'p') . ' ... ' . Shop::addSqlRestriction(Shop::SHARE_ORDER, 'product_shop')

(Alternatively, you can remove that last restriction line entirely since addSqlAssociation already constrains by shop.)

11) getReferer()

Before

FROM ' . _DB_PREFIX_ . 'connections ... ' . Shop::addSqlRestriction() . '

After

FROM ' . _DB_PREFIX_ . 'connections co ... ' . Shop::addSqlRestriction(true, 'co') . '

true is the default, but passing it explicitly is fine. The key is alias 'co'.

Final step

Clear caches after saving:

php bin/console cache:clear --env=dev php bin/console cache:clear --env=prod

That should eliminate the Column 'id_shop' in WHERE is ambiguous errors coming from dashactivity. If anything else pops up, paste that specific SQL/fragment and I’ll adjust it the same way.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...