Post by designconscious » Mon Sep 12, 2011 7:59 pm

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


Posts

Joined
Thu Sep 08, 2011 4:27 pm

Post by uksitebuilder » Mon Sep 12, 2011 8:41 pm

The data is stored in the 'setting' table as serialized data under the group name 'featured'

ImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Johnathan » Mon Sep 12, 2011 9:00 pm

...unless you're using 1.4.x, in which case it's stored in the product_featured table.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by designconscious » Mon Sep 12, 2011 9:55 pm

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)


Posts

Joined
Thu Sep 08, 2011 4:27 pm

Post by leemcgee » Tue Sep 26, 2017 1:56 am

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

New member

Posts

Joined
Mon Oct 17, 2016 6:00 am
Location - Mount Aukum, CA

Post by Charlemagne » Thu Mar 07, 2019 11:36 pm

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

Newbie

Posts

Joined
Mon Feb 05, 2018 12:42 am

Post by Johnathan » Fri Mar 08, 2019 10:10 pm

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.

Image
Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am

Who is online

Users browsing this forum: No registered users and 29 guests