Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

CSV feed import renaming file question


CotswoldEngraver

Recommended Posts

Not sure if this is possible to achieve but here goes.

I have a data feed for stock level from my supplier. The suppliers csv file is 'placed' in a folder by my supplier once a day which I then use to update my stock levels via the Get Price Quantity Update Feed using a cron. This all works absolutely fine.

The issue I have is that my suppliers csv filename changes every day because they use a date stamp as the filename. The folder where the csv is stored will have the latest file stored in a list of previously uploaded files in date order. I have asked them if they can supply me with a fixed filename but this is not possible as the file is generated by their stock control system daily and needs to be the date and time for their stock tracking.

Now to my question; is there a way of automatically renaming the file before importing it in to my site so that the add on can read a static filename? Can this be done with a standalone php file and a cron or would a line in my htaccess file work? All help gratefully received.

Kind regards Andy

Link to comment
Share on other sites

A cron job could every 30 minutes or so use glob to get file names, filemtime to see if it's new, and rename or similar to change the file to a standard name. Perhaps instead you could consider modifying the CSV code (Easy Populate?) to generate the file name from the date and directly read that (rather than a fixed name)? It would have to check for the presence of the file, in case your supplier missed a day or is late.

Link to comment
Share on other sites

Hi both.

Many thanks for your pointers on this topic.

After much experimenting I finally have a working version that sorts the files in the folder uploaded by my supplier, takes the newest one and then copies it back to the folder with a new static filename. The add on then just looks for the static filename and uploads that in to the website to update the product quantities.

I have included the additional code in to the Get Product Quantity script so the whole process runs automatically via a cron at midnight every night.

Although it is a small modification I am very pleased as this is the first time I have created a piece of code from scratch!

Thanks for your pointers.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...