SambaPOS4 Bulk Product Importer

Its the same link for 4.1.82 just scroll down to that version.

erm, how could i downgrade my database or create a new one with sql express server 2012?

I just ran the script against v4.1.82 using SQLExpress 2014 and experienced no such issues when using the sample CSV file.

The script could be made more robust for providing more default values to certain fields though… I will take a look at it.

Give this a try - I modified the PHP code quite a bit:

(attachment removed - see post later in thread for newer version)

Post any error messages that you encounter.

This is the expected output with the sample CSV file:

Start : 08:01:40
Connected successfully - MSSQL

Reading file: import.csv

Read: M1 - LABOUR ::: Brayden - Labour
Read: M2 - LABOUR ::: Bruce - Labour
Read: WORKSHOP CONSUMABLES ::: WORKSHOP CONSUMABLES
Read: $25 GIFT CERTIFICATE ::: $25 GIFT CERTIFICATE
Read: $50 GIFT CERTIFICATE ::: $50 GIFT CERTIFICATE
Read: $75 GIFT CERTIFICATE ::: $75 GIFT CERTIFICATE
Read: $100 GIFT CERTIFICATE ::: $100 GIFT CERTIFICATE
Read: ALL BALLS STEERING STEM BEARING KIT-30-140-21 (22-1013) ::: ALL BALLS STEERING STEM BEARING\rKIT-30-140-21 (22-1013)
Read: ALL BALLS BEARING KIT (22-1009) ::: ALL BALLS BEARING KIT (22-1009)
Read: RJAYS APEX HELMET S BLKBLU (RJH45BUBK3) ::: RJAYS APEX HELMET S BLKBLU\r(RJH45BUBK3)

Done reading file… Rows:10

Inserting items to DB…

Menu Category - WORKSHOP
M1 - LABOUR
M2 - LABOUR
WORKSHOP CONSUMABLES

Menu Category - GIFT CERTIFICATES
$25 GIFT CERTIFICATE
$50 GIFT CERTIFICATE
$75 GIFT CERTIFICATE
$100 GIFT CERTIFICATE

Menu Category - BEARINGS
ALL BALLS STEERING STEM BEARING KIT-30-140-21 (22-1013)
ALL BALLS BEARING KIT (22-1009)

Menu Category - HELMETS
RJAYS APEX HELMET S BLKBLU (RJH45BUBK3)

Finish : 08:01:40
Execution Time : 00:00

2 Likes

everything is just fine only this error…
seems something wrong with the warehouse

( ! ) Notice: Array to string conversion in C:\wamp\www\load_products.php on line 527
Call Stack

Time Memory Function Location

1 0.0020 342016 {main}( ) …\load_products.php:0
Exo Reptile Calcium 90G

Major modifications… tested with SambaPOS 4.1.82 and SQL Express 2014.

dbops.zip (8.1 KB)

// v3.2 (2015-05-13) QMcKay
//  - adding setting for default_charset using UTF-8
// v3.1 (2015-04-13) QMcKay
//  - changed PHP filename to dbops.php
//  - added auto-create WorkPeriod
//  - added auto-create Menu
//  - added more error checking
//  - added ExecQuery function to encapsulate Query Execution and error handling
//  - added separate functions (ops) and split into separate files:
//     - dbops_deleteproducts.php
//     - dbops_deletetransactions.php
//     - dbops_importproducts.php
//     - dbops_readproducts.php
//     - dbops_functions.php

Set your configuration options in file: dbops.php
No other files need edits.

Open Web Browser and go to address http://localhost/dbops.php
Select desired operation from the links at the top of the page…

4 Likes

@QMcKay

Hi! Does your latest post regarding SambaPOS4 Bulk Produt Importer work on SambaPOS4 version 4.1.82 and SQL Server 2014 Express?

Thank you.

Looking at this he posted above i would say yes, he has then developed it a bit more after this post so it should be fine on .82 and sql2014

Yes. SambaPOS 4.1.82 and SQL Server 2014 Express were used in testing.

2 Likes

HOW COULD I IMPORT USING UTF-8(CHINESE) ENCODING import.csv?

Honestly, I don’t know how to do that since I never use UTF-8. However, I could probably figure it out.

Can you attach your CSV file here with a few rows of data - say 10 to 50 rows?

2 Likes

Hmm… seems to work for me …


So this indicates a PHP setting problem. You can change this setting in php.ini

; PHP's default character set is set to empty.
; http://php.net/default-charset
default_charset = "UTF-8"

There are 2 things we can do:

  1. Locate php.ini and make sure it contains the setting above, and/or

  2. Modify dbops.php and put this line of code near the top of the file:

    ini_set(“default_charset”,“UTF-8”);

This is where I placed the code in dbops.php


The ZIP file above has been refreshed to include this change …

2 Likes

WOW! This is charming! THANKS!!!

Would the bulk importer script work with v3 ? If not, is there any similar script which would work for v3 to bulk import products?

Doing an install on a system running POSReady 2009 (i.e. Windows XP) and can’t update the OS.

Not sure anyone will be able to confidently answer that,
This is the V4 forum and many people have had minimal use of V3.
Easiest way to find out would be a test install and try it :stuck_out_tongue:

It will probably work for v3 but I cannot (don’t want to) confirm this. I don’t think there were many, if any, changes to the affected tables between v3 and v4.

The script was initially developed using v3. See here:

http://forum2.sambapos.org/index.php/topic,1591.msg7273.html#msg7273

1 Like

Yeah I also found that link on v3 forum after posting here. However, the download link is gone for the v1 importer file. Or I am guessing it is only visible for registered users, and registration is now closed.

Anyone have the v1 importer file referenced in that post?

I would assume this bulk product importer is included with V5 or a similar settings with similar options are integrated within v5

Nope i dont think it is so youll still need to use the setup talked about in this thread

Just try the importer in this topic, the latest of which is 3.2

I restored a v3 DB backup and tried the import. A few things are broken because of changes in some of the DB Tables. I made some changes to 1 file to make it work on v3.

  • Use the v3.2 importer package from above.
  • Download and extract the following file and replace the existing file of the same name:
    dbops_importproducts_for_SambaPOS3.zip (3.1 KB)
  • run the import operation as usual.