Importing variables e.g. Price into loads of posts
-
Hi,
I want to set up a blog with a load of products, each with a price. Then I want to update those prices as and when.
The store I’ll use can update prices from a CSV file.
I’ve looked for plugins and the like, or updating of WP’s SQL database, but nothing really fits. I also considered custom fields, but to update custom fields in the database I’ll need to know post IDs and it all has the potential to go horribly wrong, given that I’ll be adding and deleting products.
So ….. I’m thinking of each product having an associated variable, which wouldn’t be difficult from the CSV file e.g. in Excel if I have a product ID 12345 I’m sure I can easily churn out a column with that ID and associated price converted into a variable e.g $12345=£5 and then print it out
Question: Let’s say I have a thousand variables. What’s the best way of including them in WP?
As a novice PHP developer I’m thinking along these lines:
1) Require Once and include the list of variables in the header of each page. Upload the list by FTP
2) Make an array of the variables and then use foreach – don’t know if that’s got any advantages. Again, upload by FTP
3) Create a field (row? column?) in the WP database and upload variables to it, then access appropriate value with a snippet of code. Advantage – MYSQL is a lot faster at the database end than PHP?
4) Include all the variables in a post, which has the advantage of being easy to paste them in, and then access them from there. If that’s possible. (Probably not ?? )
Before I set off, can anyone point me in the right direction?
Thanks!
- The topic ‘Importing variables e.g. Price into loads of posts’ is closed to new replies.