How do I assign unique SKUs to product variants/attributes?
My company is a fulfillment warehouse. One of our new customers is using Zen Cart, so it has fallen to me to write the integration scripts to take her orders and transmit them to our in-house systems. I installed a test Zen Cart on my own server to explore the database and develop the script(s), but have run into a major snag: Product variants in Zen Cart apparently cannot be assigned individual SKUs. Yikes.
Our warehouse management system requires every unique item description to have its own product id number (SKU).
I don't need to worry about supporting "text" or "file" option types, but I do need to find a way to assign a SKU to each possible combination of the others.
A script will be set to run every hour, look for any orders in the "Processing" status, write the details of each line item of each order to a file, update the status to "Delivered", and transmit the resulting file via FTP to our warehouse's server.
A line of PHP code that could generate a line for this file (after its variables are loaded and escaped, of course) might look similar to this:
Code:
echo “$orderid|$OrderDateTime|$BillName|$ToFirstName|$ToLastName|$ToAddressLine1|$ToAddressLine2|$ToCity|$ToState|$ToPostalCode|$ToCountry|$ToPhone|$ToEmail|$ProductUPC|$ProductDescription|$Quantity|$ShippingType|$CustomerNote\r\n”;
That $ProductUPC is going to be a special challenge when products with multiple options give rise to several variants that don't each have a UPC.
I know I'm not the first to run into this. I've seen mention of this challenge elsewhere in the forum, but I haven't seen any solutions.
Has anybody succeeded at something like this?
Thanks,
Wayne
Re: How do I assign unique SKUs to product variants/attributes?
Might try out one of the Stock By Attribute plugins: Go to the Plugins area and search for "stock by attributes"
Re: How do I assign unique SKUs to product variants/attributes?
That is commonly suggested when this question has come up in the forums, and it seems like a natural thing for that plug in to do, but for whatever reason it seems not to.
Aside from that, I need to make this integration as non-intrusive as possible so that future customers who are also on Zen Cart will be able to use it as well. I can't necessarily ask that everybody installs a particular plug in.
I think what I'm going to have to do is add a table outside ZC and write a script that cycles through all the attributes of all the products periodically and populates that table with all the possible combinations. Then my script will look at each products_id and see if it appears in that table. If not, it will use products.products_model, but if so then it will use the appropriate model number from that external table. (Which also means building my own interface to manage the model numbers in that table.)
This all seems very kludgy. If anybody has a better solution, I'd sure love to hear it. :)
Re: How do I assign unique SKUs to product variants/attributes?
If you're going to write something bespoke, I suggest at least storing the data in a format that's already common to popular mods. That'll certainly reduce the barrier-to-entry for others who might consider your services.