Jump to content

Ok to Retrieve Values from Db Using Hardcoded Keys?


Recommended Posts

Do all the Prestashop based sites share the same database table structure?

For example, if I need to get the cart quantity, would it be ok to use the following command in my module, or would the 'cart quantity' key change from site to site?

$cartQty = (int)Configuration::get('cart_quantity');
Link to comment
Share on other sites

Exact same prestashop versions use exact the same data structures but with different contents. The value cart_quantity is completely unknown to me. If it has been introduced with PS 1.7. it might explain this. And keys in terms of configuration values do change sometimes, but this is very rare.

  • Like 1
Link to comment
Share on other sites

Oh got it. I'm using v1.7.1.0 Sorry I've forgotten to mention that.

So if a targeted site happens to be made on that same version, in almost all cases the db structure would be the same. But it would anyway be better to have some validations there to be on the safe side I guess.

Thank you so much for clearing this out for me.

Best Regards

Dasun

Link to comment
Share on other sites

With same ps version, the database structure is alway identical unless manually changed by a show owner or by a module. Structure means: database, table and key definitions. Not data. And yes, it's possible to check the version running on a system. Many modules do so. You find sample code in standard modules if you wish to check for that.

  • 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...