Zen Cart Logo
Forums / General Questions / Accessing Product Prices From A Remote Hosted Database....

Accessing Product Prices From A Remote Hosted Database....

Views: 1,462

Results 1 to 13 of 13
2 Aug 2012, 6:09 PM
#1
coins2012 avatar

coins2012

New Zenner

Join Date:
Jan 2012
Posts:
89
Plugin Contributions:
0

Accessing Product Prices From A Remote Hosted Database....

Hi All,

We are in precious metals business, selling coins etc. the metals prices are dynamic and changes by the minute, We have a company that will be hosting our product database with real-time price updates. We want to modify our zencart website so that when a page loads the product prices are fetched from the remote database and not from zencart database.

Could anyone tell me which files need to be changed in Zencart, we will be using an API to accress the remote database.

Right now I use easy populate to do this but it's a hassle to update 10-20 times a day.

Basically we will be bypassing the price look up.

Thank you

2 Aug 2012, 6:44 PM
#2
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Accessing Product Prices From A Remote Hosted Database....

Might be some ideas here:

http://www.zen-cart.com/downloads.php?do=file&id=761

I haven't used it.

2 Aug 2012, 6:59 PM
#3
coins2012 avatar

coins2012

New Zenner

Join Date:
Jan 2012
Posts:
89
Plugin Contributions:
0

Re: Accessing Product Prices From A Remote Hosted Database....

I appreciate that link but I really need the zencart core file that gets the price info from the zencart database, we will bypass that step and go to the remote database.

2 Aug 2012, 7:38 PM
#4
drbyte avatar

drbyte

Sensei

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

Re: Accessing Product Prices From A Remote Hosted Database....

Answer: every file that runs a query against TABLE_PRODUCTS

Yes, that's unweildy. There may be ways to minimize some of that, but prices are handled in TONS of different places, for many different reasons

It would be much simpler to write a script that does the retrieval and applies the updates for you on an automated schedule.

2 Aug 2012, 7:46 PM
#5
coins2012 avatar

coins2012

New Zenner

Join Date:
Jan 2012
Posts:
89
Plugin Contributions:
0

Re: Accessing Product Prices From A Remote Hosted Database....

DrByte:

Answer: every file that runs a query against TABLE_PRODUCTS

Yes, that's unweildy. There may be ways to minimize some of that, but prices are handled in TONS of different places, for many different reasons

It would be much simpler to write a script that does the retrieval and applies the updates for you on an automated schedule.

Wow, that's not what I expected and was afraid of that, originally my developer was going to update the database on a regular interval like you mentioned but now they want to use an API to access our product prices remotely as a hosted service.

Any idea how many files are involved?

2 Aug 2012, 7:59 PM
#6
drbyte avatar

drbyte

Sensei

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

Re: Accessing Product Prices From A Remote Hosted Database....

Are you sure that you REALLY want to use an API to load prices IN REAL TIME?

EVERY price that is displayed in Zen Cart will have to be requested separately for EVERY place ANY price is displayed on the screen, OR used in a calculation to come up with EVERY number displayed on the screen.

If you've got a very busy site, then you'll be brokering thousands of inquiries per second, effectively blasting their API server. That's very inefficient and will likely result in a very slow experience for your customer. Not to mention the technical problems it'll create for the people who run the API server.

It's much more efficient for you to run an API call, even if it's every 10 minutes, to request all the updated prices for all the products, ideally in one request if possible, and update all your store's prices accordingly. That's way more friendly to the folks who run the API server, and it's a much better experience for your customers.

2 Aug 2012, 8:11 PM
#7
coins2012 avatar

coins2012

New Zenner

Join Date:
Jan 2012
Posts:
89
Plugin Contributions:
0

Re: Accessing Product Prices From A Remote Hosted Database....

DrByte:

Are you sure that you REALLY want to use an API to load prices IN REAL TIME?

EVERY price that is displayed in Zen Cart will have to be requested separately for EVERY place ANY price is displayed on the screen, OR used in a calculation to come up with EVERY number displayed on the screen.

If you've got a very busy site, then you'll be brokering thousands of inquiries per second, effectively blasting their API server. That's very inefficient and will likely result in a very slow experience for your customer. Not to mention the technical problems it'll create for the people who run the API server.

It's much more efficient for you to run an API call, even if it's every 10 minutes, to request all the updated prices for all the products, ideally in one request if possible, and update all your store's prices accordingly. That's way more friendly to the folks who run the API server, and it's a much better experience for your customers.

The original idea was to use a cronjob and hosted database that would have all our products, the pricing would be updates every 2-5 minutes using xignite metals data feed, our hosted service would take the price of metals and calculate product prices and then the software would push the product prices to zencart database every 2-5 minutes,

Now, the developer is changing the way they like to impalement this, the hosted service is their product but now need to hook it up to zencart, I was also surprised of the change because I talked to few other people and everyone was agreed that a cronjob would be used and a hosted database with updating zencart database at a scheduled interval.

I don't think they are familiar the way zencart works, they think it's a simple few line of code.

I appreciate your input,

2 Aug 2012, 8:21 PM
#8
coins2012 avatar

coins2012

New Zenner

Join Date:
Jan 2012
Posts:
89
Plugin Contributions:
0

Re: Accessing Product Prices From A Remote Hosted Database....

HiDrByte,

"It's much more efficient for you to run an API call, even if it's every 10 minutes, to request all the updated prices for all the products, ideally in one request if possible, and update all your store's prices accordingly. That's way more friendly to the folks who run the API server, and it's a much better experience for your customers."

How would you implement the above statement, I like this idea, getting all product prices via API and I assume we will be updating the database correct?

Thank you

2 Aug 2012, 8:21 PM
#9
drbyte avatar

drbyte

Sensei

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

Re: Accessing Product Prices From A Remote Hosted Database....

While Zen Cart does have some shared functions which handle pricing, there are exceptions that are handled differently, and unless your developers are prepared to do deep code studies and extensive testing, it's most efficient to simply update the data in the place where Zen Cart expects it: the products table in the database.

Pushing updated prices every 2-5 minutes would definitely be far better in the end. Not only for customer experience, but also to minimize the amount of recoding you'll need to do in Zen Cart.
It's really quick to do:
a) fetch your updated prices via your API/feed
b) update your Zen Cart products table:

  • i) read each record from the table,
  • ii) look up its price in the data you got back from your API feed
  • iii) update the record
  • iv) repeat until finished
2 Aug 2012, 8:26 PM
#10
coins2012 avatar

coins2012

New Zenner

Join Date:
Jan 2012
Posts:
89
Plugin Contributions:
0

Re: Accessing Product Prices From A Remote Hosted Database....

DrByte:

While Zen Cart does have some shared functions which handle pricing, there are exceptions that are handled differently, and unless your developers are prepared to do deep code studies and extensive testing, it's most efficient to simply update the data in the place where Zen Cart expects it: the products table in the database.

Pushing updated prices every 2-5 minutes would definitely be far better in the end. Not only for customer experience, but also to minimize the amount of recoding you'll need to do in Zen Cart.
It's really quick to do:
a) fetch your updated prices via your API/feed
b) update your Zen Cart products table:

  • i) read each record from the table,
  • ii) look up its price in the data you got back from your API feed
  • iii) update the record
  • iv) repeat until finished

ok, that's great but where would you do this in Zencart, where would you put the code to do this.

Thank you

2 Aug 2012, 9:46 PM
#11
drbyte avatar

drbyte

Sensei

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

Re: Accessing Product Prices From A Remote Hosted Database....

If you want it to fire every 2-5 minutes, I'd use a cron job like you were initially planning.

3 Aug 2012, 3:57 AM
#12
coins2012 avatar

coins2012

New Zenner

Join Date:
Jan 2012
Posts:
89
Plugin Contributions:
0

Re: Accessing Product Prices From A Remote Hosted Database....

DrByte:

If you want it to fire every 2-5 minutes, I'd use a cron job like you were initially planning.

Hi Drbyte

Would you be interested in doing this for us, the integration part with zencart, I don't mind paying for the service.

Thank you

3 Aug 2012, 4:23 AM
#13
drbyte avatar

drbyte

Sensei

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

Re: Accessing Product Prices From A Remote Hosted Database....

Coins2012:

The original idea was to use a cronjob and hosted database that would have all our products, the pricing would be updates every 2-5 minutes using xignite metals data feed, our hosted service would take the price of metals and calculate product prices and then the software would push the product prices to zencart database every 2-5 minutes,
Have they explained why they changed their mind?

Seriously, pulling the data from Zen Cart's table is as simple as selecting each row from the products table. And updating the price is as simple as updating that record with the new amount.
It's not even about "integrating" with Zen Cart because it can (and should) be done completely separate from Zen Cart itself, by simply doing direct queries on the database.

Does your developer really not know how to access and run queries on a MySQL database table?

Without knowing the bigger picture about why this developer has changed their mind and is suddenly unable to do what they originally proposed, I really can't give you specific technical help.