Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-07-22 04:20:07

HarryG
Member
Registered: 2011-01-12
Posts: 21

Your advice is sought for my online bookshop

I have already written some php code to query a custom database and display the more than 1,000 titles in our inventory. Still, I wonder if I might be better off importing the book data into Textpattern. Trouble is, I have 15 fields that must be displayed.

The info I need to display is:

  1. Stock no.
  2. Title
  3. Subtitle
  4. Author
  5. Author of preface, intro, etc
  6. Qty in stock
  7. ISBN
  8. Published year
  9. Arrival date (for “Coming soon”, or “Recent Arrivals” lists)
  10. Page count
  11. Weight
  12. Size
  13. Price (Local currency)
  14. Price ($US)
  15. Sales restriction (Worldwide, worldwide to members only, local sales only)

Question #1: Is there any way to apply all 15 variables to a data record in Textpattern?

Periodically I will be receiving some spreadsheets from the warehouse manager. These will contain updated QTY IN STOCK, new, and deleted items. I have already written macros that will convert the spreadsheets into UPDATE, INSERT, and DELETE queries for my own database.

Question #2: Is there a way to do the same thing in Textpapttern? That is, issue queries directly to phpmyadmin to update the article database? I sure don’t want to have to update 1,000 records every week to input the new quantities in stock.

Thanks…

HarryG.

Offline

#2 2011-07-22 09:22:30

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: Your advice is sought for my online bookshop

Hi HarryG.,

Is there any way to apply all 15 variables to a data record in Textpattern?

There are custom_fields! By default there are 10 but these can be easily increased. These would fit your needs.

Is there a way to do the same thing in Textpapttern? That is, issue queries directly to phpmyadmin to update the article database? I sure don’t want to have to update 1,000 records every week to input the new quantities in stock.

Textpattern is PHP and MySQL so you can build whatever you want.

Example:

  • Create JSON, XML or CSV from the spreadsheets. Build a small API/webservice for Textpattern (maybe this could work with the included RPC) which accept the file and update the DB or
  • quick ‘n’ dirty: Export your spreadsheet to CSV, write a CSV-to-MySQL-import script for textpattern and upload/import the file once in a week.

Last edited by trenc (2011-07-22 09:24:50)


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#3 2011-07-22 14:21:43

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,945
Website GitHub

Re: Your advice is sought for my online bookshop

trenc wrote:

Create JSON, XML or CSV from the spreadsheets. Build a small API/webservice for Textpattern

You can read XML data into Txp using smd_xml. Just give it a URL or a string of XML data. I’m working on improvements to this plugin and would welcome the ability to get my teeth into doing something on this scale so, HarryG, do get in touch if you need assistance or you end up trying the plugin. The version I have in development does a lot more than the currently released version.

fwiw, inside your smd_xml container you can put smd_query tags if you like, which may save you having to code calls to safe_update() / safe_insert() yourself: the error handling and data sanitization options are all built into the plugin.

Export your spreadsheet to CSV, write a CSV-to-MySQL-import script for textpattern and upload/import the file once in a week.

There’s a batch upload plugin for CSV data. Not sure if it does UPDATEs as well as INSERTs as I’ve never used it. Think its called jmd_csv, but I might be wrong.

Last edited by Bloke (2011-07-22 14:22:35)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB