VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: biker_bits on July 17, 2016, 14:24:55 PM

Title: Stock status - from non-numeric CSV (Red, Yellow, Green)
Post by: biker_bits on July 17, 2016, 14:24:55 PM
Joomla! 2.5.28
VM 3.0.16
CSVI Free 5.15

Hi

Been trying to work around this for a while now...

Just wondered if it is possible to import stock level from a CSV as a word (red, yellow, green) instead of a numeric value?
Unfortunately, this is how the suppliers stock control file is formatted - giving a colour word instead of a value for the actual quantity.

Which (custom?) field can I import this into with CSVI? Then display a dot or a graphic on a product flypage.

Any ideas will be much appreciated!

Title: Re: Stock status - from non-numeric CSV (Red, Yellow, Green)
Post by: Studio 42 on July 17, 2016, 23:05:32 PM
I think, it's easier to add a new columns and set value depending the string in your sheet directly.
Eg if(red) then 0 else if yellow then 1 else if green then 2. Of course you need to convert this formule for your software
Another simple solution, is to search & replace this column directly.
Title: Re: Stock status - from non-numeric CSV (Red, Yellow, Green)
Post by: biker_bits on July 18, 2016, 15:38:46 PM
Thank you for your reply!

Even if I replace a colour letter/word in the feed with a numeric code, how do I import this into VM to show corresponding stock level?

Sample CSV attached as an XLS.

Title: Re: Stock status - from non-numeric CSV (Red, Yellow, Green)
Post by: Studio 42 on July 18, 2016, 17:12:41 PM
I don't know how you handel your stock, i only give you a possible solution.
If nothing can be associate, i don't know how you want update a stock.
Title: Re: Stock status - from non-numeric CSV (Red, Yellow, Green)
Post by: biker_bits on July 18, 2016, 17:18:50 PM
Stock update comes from the supplier like the attached file. We don't have any control over the format it is in.
It would be much simpler if they showed quantity!
I was just wondering if there was any way of creating a new variable to display the status pulled from the file? Or maybe I was missing an already existing one?

Thank you for all your help!
Title: Re: Stock status - from non-numeric CSV (Red, Yellow, Green)
Post by: biker_bits on July 18, 2016, 17:33:44 PM
Just came across this: http://forum.virtuemart.net/index.php?topic=92756.0

I wonder if :

Tell the customer the stock is low, and they should order NOW!

<?php if ($this->product->product_in_stock <= 10) { ?>
                  <div>ONLY <?php echo $this->product->product_in_stock ?> In Stock. ORDER BEFORE IT'S TOO LATE</div>
               <?php    }?>

Could be altered to say (replace 10 with Y):

Tell the customer the stock is low, and they should order NOW!
<?php if ($this->product->product_in_stock = Y) { ?>
                  <div>ONLY <?php echo $this->product->product_in_stock ?> In Stock. ORDER BEFORE IT'S TOO LATE</div>
               <?php    }?>

Would this work?
Title: Re: Stock status - from non-numeric CSV (Red, Yellow, Green)
Post by: Studio 42 on July 18, 2016, 18:47:24 PM
Why you don't use number, as explained before?
You import stock on replacing each color by a number
Eg
red stock 0
yellow stock 2
green stock 10.
YOu can search and replace in your xls file directly and import the csv to update all days.
Title: Re: Stock status - from non-numeric CSV (Red, Yellow, Green)
Post by: biker_bits on July 20, 2016, 09:29:30 AM
Now I understand how you meant to implement this! Thank you!
I'll try than when I get a minute and report back
Title: Re: Stock status - from non-numeric CSV (Red, Yellow, Green)
Post by: biker_bits on July 20, 2016, 11:41:44 AM
It works!
THANK YOU for this simple and genius solution!

The only thing... it either shows red=0 or green=anything else. I've tried setting CSV to 1 for yellow - still shows green.
Where does VM set level at which indications change?
Title: [SOLVED]Re: Stock status - from non-numeric CSV (Red, Yellow, Green)
Post by: biker_bits on July 20, 2016, 12:52:33 PM
Worked how to get yellow indication to work too ...

You can see that field from:
VM Backend >> Products >> [Any Product] >> Product Status >> [Low Stock Notification]


Above borrowed from https://www.flexiblewebdesign.com/forum-virtuemart-2-template-fashionmart-support/1643-stock-level-icon-in-category-pages


...or for bulk changes - set notification qty via CSV, using low_stock_notification variable  for each SKU.

Studio 42- HUGE 'thank you' again - SOLVED!  :)