Troubleshooting

Error "Shop not found at line xxx in file classes/shop/Shop.php"

Reviewed on 3 min read base de datos errores prestashop

Shop not found at line xxx in file classes/shop/Shop.php means PrestaShop could not load a valid shop. The exception alone does not prove that PS_SHOP_DEFAULT is the original cause.

In the front office, PrestaShop first tries to identify the shop that matches the requested domain and path. If that shop is not resolved, does not load or is not active, it tries to open the shop defined by PS_SHOP_DEFAULT; the exception appears when it cannot load that fallback either.

// No shop found ... too bad, let's redirect to default shop
$default_shop = new Shop((int) Configuration::get('PS_SHOP_DEFAULT'));

// Hmm there is something really bad in your Prestashop !
if (!Validate::isLoadedObject($default_shop)) {
    throw new PrestaShopException('Shop not found');
}

Keep the exact URL and the trace before changing the database. In a multistore installation, check these relationships using the real table prefix:

  • In PREFIX_shop_url, check domain, domain_ssl, physical_uri, virtual_uri, main and active for the host and path that fail.
  • In PREFIX_shop, confirm that the shop obtained and the default shop exist, are active and are not marked as deleted.
  • In PREFIX_configuration, list all the PS_SHOP_DEFAULT rows together with id_shop_group and id_shop. The effective value can depend on the group or shop context.

Do not edit the first row you find or copy an ID from another shop without checking the context. Make a database backup first and test the fix on a clone; a wrong URL or default shop can affect every front office request.

If you cannot work out which scope Configuration::get() resolves, contact support and give the domain, the failing path, the approximate time and the trace. Do not send credentials in the ticket.

Check domain and path before touching data

If it happened after a domain change, first confirm which server the request reaches and which document root it uses. A correct database does not prevent the error if you are opening another copy of the shop with a host it does not have registered.

After the minimal fix, test HTTP/HTTPS, the chosen variant with or without www, an inner page and the back office. In multistore, also check the shops that were not supposed to change and that the fallback does not send the visitor to another catalogue.

You may also find useful

Something wrong or out of date? Tell us and we will review it.