Forums / General Questions / Is it possible to "read" stock availability from a separate store?

Is it possible to "read" stock availability from a separate store?

Views: 654

Results 1 to 5 of 5
10 Aug 2012, 4:45 AM
#1
kiwijetpilot avatar

kiwijetpilot

New Zenner

Join Date:
Aug 2012
Posts:
2
Plugin Contributions:
0

Is it possible to "read" stock availability from a separate store?

I assume not, but thought I would ask anyway.

A client wants his site to mirror the stock availability of another website, which runs Zen cart (as he is a re-seller of products from the other site). Is that possible? I assume not, on security grounds, but I don't know anything about Zen Cart, so you never know... ;)

10 Aug 2012, 5:35 AM
#2
drbyte avatar

drbyte

Sensei

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

Re: Is it possible to "read" stock availability from a separate store?

For security and technical reasons, the short answer is no. Especially if you're talking about real-time information, since the remote queries would slow things to a crawl.

But you could write a timed script to periodically go out and get the information (assuming you also build the appropriate security/authorization logic to allow it) and then use that info to update data in your own site with the changes, say every 15 minutes or so.

There are performance/caching caveats with doing regular mass updates, so I wouldn't do it more often than 10-15 minutes apart. Better to make it even longer if that suits your business.

So the long answer is yes, if you're prepared to roll up your sleeves to make it work.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

10 Aug 2012, 7:04 AM
#3
torvista avatar

torvista

Totally Zenned

Join Date:
Aug 2007
Location:
Gijón, Asturias, Spain
Posts:
2,876
Plugin Contributions:
7

Re: Is it possible to "read" stock availability from a separate store?

How about the source site creates a csv of product stock regularly and the destination site imports it regularly?
No need for access control or synchronisation?

Steve
github.com/torvista: BackupMySQL, Structured Data, Multiple Copy-Move-Delete, Google reCaptcha, Image Checker, Spanish Language Pack and more...

10 Aug 2012, 11:33 AM
#4
kiwijetpilot avatar

kiwijetpilot

New Zenner

Join Date:
Aug 2012
Posts:
2
Plugin Contributions:
0

Re: Is it possible to "read" stock availability from a separate store?

Many thanks for the replies folks.

My assumption is that a timed script would only work if one had the appropriate permissions to look at the database? The problem being that the owners of the source site are unwilling to allow access to their database (ie passwords etc). The client thinks that, as it is possible to look at stock levels by viewing each individual shop item one at a time, it should be possible to "trawl" the site for stock data... using an appropriate script. Something tells me that it is unlikely to be that easy though... what do you think?

10 Aug 2012, 5:03 PM
#5
drbyte avatar

drbyte

Sensei

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

Re: Is it possible to "read" stock availability from a separate store?

Trawling or scraping the data is a poor practice.
If there's a relationship whereby the site trusts you with having up-to-date stock info, then there are various ways for them to share the data with you.

What I wrote earlier was intentionally very generic. I said "have your script go out and get the data" ... that "go out and get" could be in various forms (direct database access, a REST query, a CSV file produced by their end and stuffed into a URL that your script can read, etc).

torvista suggested one approach ... have them set up a timed script on their end to export a CSV file of product ids and inventory counts. Then have your script read and process that info.

If they will write a script that extracts the data and puts the CSV file into a folder on their server (a folder not advertised to anyone but you, and maybe security-restricted to only the IP address of your webserver), then your script could check to see whether the file exists, and process it.

I also wrote generically in how to process the script, mentioning that it should only apply updates where a change is needed. ie: if there is no info for a particular product ID, skip it. And if the quantity they say they have matches what you have, then skip it. This minimizes the amount of changes pushed into your database, thus minimizing performance problems.

Of course if you're asking for more info than just product ID and available stock for that ID, then things get more complicated.

But there are lots of ways to tackle your situation as you described it.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.