Zen Cart Logo
Forums / Setting Up Categories, Products, Attributes / Force update all products

Force update all products

Views: 1,464

Results 1 to 20 of 21
15 Apr 2016, 9:31 AM
#1
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Force update all products

I need to add some default values to all products which I plan to do through MYSQL so all products have the same values for product descriptions.

In order to pick up the values from the database, Zen Cart requires each product to be updated through the admin. There's alot of products so how would I force the admin to update all products at the same time rather than going through each one and clicking 'Preview' then 'Update'

15 Apr 2016, 10:04 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Force update all products

There is a SQL tool where you can enter your SQL to perform your desired action. In admin->tools->install sql patches.

When entering your sql, refer to the table(s) without a prefix, ie. products not zen_products, and be sure to end your sql query with a semi-colon (;).

Suggest backing up your database before doing any of this though...

As for the above description, in one place identified the need to update the description, in another stated that all that was needed was to select preview then update. While the above explanation accomplishes the first part, it doesn't accomplish the second... Was that just information left off, or are you expecting an action that is normally performed upon moving through preview to update to also be performed?

15 Apr 2016, 11:02 AM
#3
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Force update all products

mc12345678:

or are you expecting an action that is normally performed upon moving through preview to update to also be performed?

Yes I am expecting the update to be performed without the need to login and go through every product to update them one by one once fields have been updated in the database.

15 Apr 2016, 3:05 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Force update all products

Nick1973:

In order to pick up the values from the database, Zen Cart requires each product to be updated through the admin.
Please explain more about this "requirement".

The only such "requirement" I can think of is a recalculation of the cached values of products_price_sorter which contains the lowest available price based on applicable discounts. And you can force the recalculation of this via Admin->Tools->Store Manager.

What other "requirements" are you saying need to be done?

15 Apr 2016, 3:17 PM
#5
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Force update all products

Ok, I have added some extra fields and I want to apply a default value to these in MYSQL. The fields in MYSQL update in the database, however they don't update in the admin or on the front end as I would need to click preview and then update for them to process.

15 Apr 2016, 4:24 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Force update all products

Nick1973:

Ok, I have added some extra fields and I want to apply a default value to these in MYSQL. The fields in MYSQL update in the database, however they don't update in the admin or on the front end as I would need to click preview and then update for them to process.
Then, since only you know the unique custom updates required for those fields, perhaps it's best that you write the SQL queries that will auto-update those fields the same way you've coded the Preview/Update pages to update them.

15 Apr 2016, 5:01 PM
#7
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Force update all products

Nick1973:

Yes I am expecting the update to be performed without the need to login and go through every product to update them one by one once fields have been updated in the database.
Well, see, there's a difference between running a sql to update the data and the actions that can be programmed into the evolution of preview to update. There are plugins that call additional code during this preview/update process which would not get activated when running a sql command. Therefore, if wanting action to be taken exactly related to the process performed by ZC during the review/update process then something else needs to be considered besides a sql command. This may now be a duplicate of DrBytes response, but I already wrote this, so submitting anyways. :P

15 Apr 2016, 5:03 PM
#8
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Force update all products

Your answer doesn't really help that much to be honest in this instance. Perhaps give me an idea of what I should write, that would be a starting point.

15 Apr 2016, 5:13 PM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Force update all products

mc12345678:

There are plugins that call additional code during this preview/update process
Please elaborate. Which plugins? And what do they do?

EDIT: mc12345678 ... sorry, I thought you were Nick1973 there.
If there are actual plugins involved here, we need to know what they are.

There's nothing in ZC currently that automatically simulates the whole preview/update process.

There isn't enough info available about what the actual updates are that Nick1973 needs to fire on all records.

Nick1973:

Your answer doesn't really help that much to be honest in this instance. Perhaps give me an idea of what I should write, that would be a starting point.
I can't give you any useful help without knowing entirely how you've altered your site from original Zen Cart code. Maybe my crystal ball needs polishing?

15 Apr 2016, 5:15 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Force update all products

Is this whole discussion entirely related to your other discussion too? Strip HTML and WORD formatting
Or is there more beyond that?

15 Apr 2016, 5:32 PM
#11
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Force update all products

I'll try and make this simple so you don't have to bother polishing your crystal ball Mr Byte! Hopefully I can save you and your duster a job.

I've added four simple text fields

text1

text2

text3

text4

They are all added into the table 'products' in the database and show up as empty fields in the Zen Cart admin on the product information page.

Each field should have a default value, however as they are new fields the default value does not show up on the front end or in the admin panel.

15 Apr 2016, 5:32 PM
#12
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Force update all products

No its nothing to do with stripping html tags, that is independent.

15 Apr 2016, 5:46 PM
#13
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Force update all products

Nick1973:

I've added four simple text fields

text1

text2

text3

text4

They are all added into the table 'products' in the database and show up as empty fields in the Zen Cart admin on the product information page.

Each field should have a default value, however as they are new fields the default value does not show up on the front end or in the admin panel.
Okay. How does using the Preview/Update page in the admin set a value into those fields? How is that value calculated/determined in your site?

And why can't you run a simple SQL query to set those fields the same way?
ie: ```
update products set text1='default1', text2='default2', text3='default3', text4='default4' where text1='';

or for more detailed control:```
update products set text1='value1' where text1='';
update products set text2='value2' where text2='';
update products set text3='value3' where text3='';
update products set text4='value4' where text4='';

Or is there a calculation performed? If so, what?

15 Apr 2016, 5:51 PM
#14
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Force update all products

It is just plain text, not a calculation. The default value should automatically show in each field in the admin and on the front end, without having to go through every product and trigger an update to each individual product.

15 Apr 2016, 5:56 PM
#15
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Force update all products

Nick1973:

It is just plain text, not a calculation. The default value should automatically show in each field in the admin and on the front end, without having to go through every product and trigger an update to each individual product.
Okay, then the 2nd SQL I posted above should take care of fixing all the records you've already inserted (or which are blank because of how you added the fields to the database without specifying a default).

And you could change the default value on those fields, in the database schema itself, to something other than blank, so that new records you inject from an external source automatically get that defined default.

Or, you could experiment with the Easy Populate plugin that mc12345678 has been updating and maintaining recently, to do all this editing in a spreadsheet which you can upload to replace the data in your database, periodically as necessary.

15 Apr 2016, 6:10 PM
#16
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Force update all products

So are you saying that if I specify a default when creating the fields in the database, then it will cause Zen Cart to automatically see the default? If so then the easier option would be just to recreate the fields with the default.

15 Apr 2016, 6:12 PM
#17
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Force update all products

Somewhat following up in the rear with this, it is possible to add a default value for new input when using the ZC standard product entry. That said, it may have already been added, seeing that 1) question related to it hasn't been asked, and 2) such a process (edit and update each product) appears possible at this time.

Yes, EP4 could be used to modify product table entries.

In regards to a plugin that does "require" stepping through the preview/update process, CEON URI Mapping does make modifications as well as Numinix additional fields to name a few... though Numinix's fields are basically additional products table fields, but one could always add some sort of processing function to the code instead of perhaps AJAX to accomodate whatever concept.

15 Apr 2016, 6:17 PM
#18
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Re: Force update all products

I tried Numinix Products Fields, but while I have used it on other installs, I'm not entirely sure why, but it wouldn't see the fields so I decided to create the fields myself manually which was in fact alot easier in this case anyway.

15 Apr 2016, 6:19 PM
#19
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Force update all products

Nick1973:

So are you saying that if I specify a default when creating the fields in the database, then it will cause Zen Cart to automatically see the default? If so then the easier option would be just to recreate the fields with the default.
Yes .

15 Apr 2016, 6:23 PM
#20
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Force update all products

mc12345678:

In regards to a plugin that does "require" stepping through the preview/update process, CEON URI Mapping does make modifications
Yes. Those are brutally intrusive, and a mess to recreate the way Nick1973 is asking here. Thankfully he hasn't mentioned that. That would require writing a bunch of custom scripts to do it ... something the CEON URI mod doesn't provide, but they're happy to charge extra for if you can find someone there to respond anymore now that Conor's family has taken it over.