Post by endless882 » Mon Nov 30, 2020 2:36 am

Good evening. May someone help me to make php script with sql or few sql queries that must do the following:

First - there is a table made by extension and called (oc_product_newtabcontent)
Inside we have 2 records, it makes 2 or more records depending on how many languages the shop's got. In my case I have 2...
Here's how this table structure looks like:
Image

This extension allow me to add extra tab (next to product description tab) - okay. But with all the products I have, doing this manually... will take time
So - Ive already added to 1 product the necesary information which has to contain - May you write a simple php cycle which gets all products from the main product table, and making new records in this table for each product id? Reminder: there are 2 records per product just because of the language

Here it is:
Image

It has to make such records for all existing products, copying the (newtabcontent) column to each record. Also something important is that this column (newtabcontent) has different value in language_id 1 and language_id 2

I hope I've explained it correctly - It's not so hard but it's been years since I havent been web-developing ... - Thank you!

New member

Posts

Joined
Wed Jul 29, 2020 11:04 pm

Post by by mona » Mon Nov 30, 2020 2:43 am


DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by endless882 » Mon Nov 30, 2020 2:57 am

by mona wrote:
Mon Nov 30, 2020 2:43 am
https://www.databasejournal.com/scripts/
Not useful at all. You could at least provide with something closer to a solution. Thanks anyway

New member

Posts

Joined
Wed Jul 29, 2020 11:04 pm

Post by by mona » Mon Nov 30, 2020 3:25 am

I was suggesting you ask there ..

but ok, fair enough .. how about these

https://www.google.com/search?client=sa ... 8&oe=UTF-8
https://www.w3schools.com/sql/sql_insert.asp

and far more importantly, make sure you back up your database before messing with it.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by sw!tch » Mon Nov 30, 2020 4:11 am

Is it the same content for each tab? You can probably do this with a simple query and loop from the product_description table.
Last edited by sw!tch on Mon Nov 30, 2020 4:23 am, edited 1 time in total.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by endless882 » Mon Nov 30, 2020 4:23 am

sw!tch wrote:
Mon Nov 30, 2020 4:11 am
Is it the same content for each tab? You can do this with a simple foreach loop on products and again on language.
Yes the same. In this table has to exist 2 records per each of the existing products... one with language_id 1 and one with language id 2 and with same content on (newtabcontent) *copied from the existing 2 rows*

New member

Posts

Joined
Wed Jul 29, 2020 11:04 pm

Post by sw!tch » Mon Nov 30, 2020 4:26 am

You should be able to just query the product_description table and then exec your logic for the tab insert from the result loop. You can further get language id and product id from that same.. loop.

If you are not versed in coding or new to OC - Look at the admin/model/catalog/product.php. methods, probably some examples in there you can reference or build from.

Backup if messing with code and the DB, etc.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm

Post by wrick0 » Mon Nov 30, 2020 7:32 pm

This should work but is probably not the best way to do it, just wrote this for you in a few minutes

change your database information to your opencart db (backup ur db first)

Change the $newtabcontent 1 and 2 and $name1 and $name2 to your data :)

if you need help pm me

Active Member

Posts

Joined
Fri Jan 18, 2019 10:00 pm
Location - 127.0.0.1 @ The Netherlands
Who is online

Users browsing this forum: No registered users and 203 guests