Hi,
I want to be able to set a product to featured directly into the database.
I know how to do it via the admin, but I can't see which table or field is updated to identify that product as featured. The reason I want to do it direct from the database is my client is uploading his data direct and wants to be able to set the product as featured from within his own system.
Can any one help me please?
Ian
Hi Johnathan,
Sorry my bad, I should have said it's Version 1.5.1
So I see the record with the key featured_product has an array of product ID's great thanks for the help!
Ian
(Johnathan I have another issue that might need some coding detailed here http://forum.opencart.com/viewtopic.php?f=20&t=40433 if you are interested or think you can help)
Sorry my bad, I should have said it's Version 1.5.1
So I see the record with the key featured_product has an array of product ID's great thanks for the help!
Ian
(Johnathan I have another issue that might need some coding detailed here http://forum.opencart.com/viewtopic.php?f=20&t=40433 if you are interested or think you can help)
In 2.3.0.2, don't know when this started:
select setting from oc_module where code='featured'
gets the serialized and NON-RELATIONAL (!) list of featured product ids in the "setting" text column. Hard to update with mysql SQL, but can be done. The product_ids are even character not integer! I would love to see the actual SQL from the featured module code. And my hopes and dreams are to see the opencart developers do relational database properly again and bring back the product_featured table. I have been doing relational database for over forty years now, this is a bad situation. Lee McGee
select setting from oc_module where code='featured'
gets the serialized and NON-RELATIONAL (!) list of featured product ids in the "setting" text column. Hard to update with mysql SQL, but can be done. The product_ids are even character not integer! I would love to see the actual SQL from the featured module code. And my hopes and dreams are to see the opencart developers do relational database properly again and bring back the product_featured table. I have been doing relational database for over forty years now, this is a bad situation. Lee McGee
Looks like the setting field is a Python class. This would be executed directly in Python so you wouldn't manipulate this in SQL.
I, too, am an old SQL hack (since 1982 with interruptions). The world is changed. https://youtu.be/4L_3JrRSMQ4?t=34
I, too, am an old SQL hack (since 1982 with interruptions). The world is changed. https://youtu.be/4L_3JrRSMQ4?t=34
OpenCart 2 and OpenCart 3 store all module data in the "module" table. The settings for the module are stored as PHP serialized strings in OpenCart 2.0, and as json-encoded strings in OpenCart 2.1 and later. Updating them using PHP is a simple matter of unserializing or json-decoding the string into an array, modifying the array, then re-serializing or re-encoding the array before inserting it into the database. If you're trying to do it completely using MySQL then yes it would be much harder, since the array is based on PHP functions and not a relational database table.
In OC3 Featured products are stored as plain-text-product ID's in the filed "setting" in the table oc_module, where the filed "name" is "Home Page" and "code" is "fetaured". Here you can easy edit the order of the featured products, for example in phpMyAdmin. I just change the product ID's and it worked without using any "json-decoding" back and forth.
Who is online
Users browsing this forum: No registered users and 203 guests