MrGettingRatherFrustrated Posted September 9, 2021 Share Posted September 9, 2021 I have the need to import a number of products from a csv/txt file, preferably including dynamic translations but its not essential. Does anyone have a solution they would be willing to share? Many thanks in advance Rob 0 Quote Link to comment Share on other sites More sharing options...
string Posted September 10, 2021 Share Posted September 10, 2021 Unfortunately I do not have a premade script (and I don't think anyone can give you a completed script, since the format in your file will surely be different and the requirements may also), but in case you haven't seen it, WHMCS offers an API for adding products: AddProduct API. 0 Quote Link to comment Share on other sites More sharing options...
MrGettingRatherFrustrated Posted September 10, 2021 Author Share Posted September 10, 2021 Thanks String, I did see the API and can add a single product using the sample code however I am not a developer so taking it further so that I can bulk import is beyond me, I'm not too bad at hacking and adapting working scripts though I am a little baffled why this is still not a capability of WHMCS itself as there seem to have been many requests over the years and would obviously help anyone who wanted to migrate to WHMCS although the trend does seem to be to move away ... 0 Quote Link to comment Share on other sites More sharing options...
string Posted September 10, 2021 Share Posted September 10, 2021 If you are not too bad at hacking scripts together, feel free to post a sample line of your CSV and i will post an example script 🙂 0 Quote Link to comment Share on other sites More sharing options...
MrGettingRatherFrustrated Posted September 11, 2021 Author Share Posted September 11, 2021 That is incredibly kind string, I am most grateful for your offer An example with header row and text below - the header rows correspond to the WHMCS tblproducts and the last two columns to tblpricing database (MFG & MPN are two columns that I have added to the WHMCS database) type,gid,name,description,MFG,MPN,welcomeemail,paytype,allowqty,servertype,tax,currency,monthy other,21,Test Product,This is a test product,Test,ABC-01234,21,onetime,2,,1,1,99.99 Regards Rob 0 Quote Link to comment Share on other sites More sharing options...
string Posted September 11, 2021 Share Posted September 11, 2021 The file must be uploaded into the root directory of your WHMCS installation. I suggest to test it first in a developer WHMCS installation 🙂 I am not sure if your custom columns MFG / MPN are in tblproducts, so you would have to adjust the script if it is in tblpricing. importProducts.zip 1 Quote Link to comment Share on other sites More sharing options...
MrGettingRatherFrustrated Posted September 11, 2021 Author Share Posted September 11, 2021 Thank you so much, you really are very kind 🙂 I will test 0 Quote Link to comment Share on other sites More sharing options...
MrGettingRatherFrustrated Posted September 11, 2021 Author Share Posted September 11, 2021 1 hour ago, MrGettingRatherFrustrated said: Thank you so much, you really are very kind 🙂 I will test It works great, thank you very much indeed. I had to change the allowqty to use the post add logic you had as thats not available on the API The only thing I'm still trying to work out is how (if) I can add multiple currencies to the price table in one go - I will carry on fiddling 🙂 0 Quote Link to comment Share on other sites More sharing options...
string Posted September 12, 2021 Share Posted September 12, 2021 (edited) 9 hours ago, MrGettingRatherFrustrated said: The only thing I'm still trying to work out is how (if) I can add multiple currencies to the price table in one go - I will carry on fiddling Thats pretty easy, we have this line in the script: $data['pricing'][$values['11']]['monthly'] = $values['12']; $values['11'] is the currencyId from the CSV and $values['12'] the monthly pricing. If you want to add a second currency, you would add: $data['pricing'][$currencyId]['monthly'] = 'PRICE'; // $currencyId = e.g. "2" Edited September 12, 2021 by string 0 Quote Link to comment Share on other sites More sharing options...
Athena-Divine Posted August 26, 2023 Share Posted August 26, 2023 On 9/11/2021 at 4:45 PM, string said: The file must be uploaded into the root directory of your WHMCS installation. I suggest to test it first in a developer WHMCS installation 🙂 I am not sure if your custom columns MFG / MPN are in tblproducts, so you would have to adjust the script if it is in tblpricing. importProducts.zipUnavailable I was wondering if I could get the spreadsheet for this. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.