I would say using phpmyadmin you should be able to do this. There would be a query you could run that will populate all the fields with 15 or whatever stock level you want. Im not sure what the query would need to be exactly though.
I would say using phpmyadmin you should be able to do this. There would be a query you could run that will populate all the fields with 15 or whatever stock level you want. Im not sure what the query would need to be exactly though.
This depends on what version of the mod you are running.
If you are using the version 1.5.1.2, than this functionality is built into the installation script as a selection.
After installation you can use the "Run Optional SQL", This script will Makes entries into the new SBA Table based on the products that have attributes associated.
After running the script you can do an export 'Export Table Data' of the table to a CSV file and update the stock using excel (save file as CSV), use "Import Table Data'... This is explained in the documentation under Optional SQL:
Optional.sql
The Optional SQL script is intended to initially fill the stock table with the same quantity that the product has. The script only creates entries for products that have associated attributes.
The first time the script is run on a clean new installation (the new SBA stock table is empty), then all found records are added.
Backup Files and Databases First. GitHub
Suggestions, Plugins, etc. used at your own risk.
I'm having a problem that I can't find reference to on this thread.
When I have a product with attributes and stock for each attribute a customer can choose to order whichever version they want. However when they check out, stock is removed from the overall stock levels for the product, but not for the particular attribute.
For example, if I have product A with variants Ab and Ac, and I start with stock of 10 each. A customer purchases 5 in variant Ac; my stock for product A now says 15, but Ab shows as 10, and Ac shows as ten. Worse (which has happened) a customer buys all of Ac, but then the next customer can still choose to buy 10 more that don't exist.
I am using V1.5.0, SBA version 1.5.0, however I was having the same issue with an earlier SBA which I uninstalled over the summer and re-installed just recently. I merged all of the files needed, and everything else seems to work.
Any ideas on where to even start looking?
Thanks.
Hi,
The code that should be doing this is in: includes\classes\order.php on about line 739, with the title:
// kuroi: Begin Stock by Attributes additions
// added to update quantities of products with attributes
I was not aware this did not work correctly.
This is an area of the code I have not looked closely at yet. If you solve the problem, would you let us know, I am working on an updated version of this mode to include some additional features, and could add that fix.
Backup Files and Databases First. GitHub
Suggestions, Plugins, etc. used at your own risk.
In my case it works fine.
I have Product A with 3 attributes.
Prod A, Attribute A (9 QTY)
Prod A, Attribute B (3 QTY)
Prod A, Attribute C (1 QTY)
Displaying 13 Units in Stock
When I checkout one (purchase) from Prod A, Attribute B. After checkout, product_info page displays:
Prod A, Attribute A (9 QTY)
Prod A, Attribute B (2 QTY)
Prod A, Attribute C (1 QTY)
Displaying 12 Units in Stock
It works fine for me.
Using Zen Cart 1.5.1
Tried another test. Checked out 5 of units of Prod A, Attribute A
Prod A
Attribute A (4 QTY)
Attribute B (2 QTY)
Attribute C (1 QTY)
Displaying 7 Units in Stock
Code works fine here.
Last edited by Kevin205; 2 Oct 2013 at 06:05 AM.
Using Zen Cart 1.5.1
Thanks for the ideas. The file you referenced was replaced in the install, so it should be fresh. Here is the code in that section, it all looks good to me, but I'm not an advanced code reader...
I also re-checked my stock config settings and everything seems to be correct.
// kuroi: Begin Stock by Attributes additions
// added to update quantities of products with attributes
$attribute_search = array();
$attribute_stock_left = STOCK_REORDER_LEVEL + 1; // kuroi: prevent false low stock triggers
if(isset($this->products[$i]['attributes']) and sizeof($this->products[$i]['attributes']) >0){
foreach($this->products[$i]['attributes'] as $attributes){
$attribute_search[] = $attributes['value_id'];
}
if(sizeof($attribute_search) > 1){
$attribute_search = 'where options_values_id in ("'.implode('","', $attribute_search).'")';
} else {
$attribute_search = 'where options_values_id="' . $attribute_search[0].'"';
}
$query = 'select products_attributes_id from ' . TABLE_PRODUCTS_ATTRIBUTES . ' ' . $attribute_search .' and products_id="' . zen_get_prid($this->products[$i]['id']) . '" order by products_attributes_id';
$attributes = $db->Execute($query);
$stock_attributes_search = array();
while(!$attributes->EOF){
$stock_attributes_search[] = $attributes->fields['products_attributes_id'];
$attributes->MoveNext();
}
if(sizeof($stock_attributes_search) > 1){
$stock_attributes_search = implode(',', $stock_attributes_search);
} else {
foreach($stock_attributes_search as $attribute_search){
$stock_attributes_search1 = $attribute_search;
}
$stock_attributes_search = $stock_attributes_search1;
}
$get_quantity_query = 'select quantity from ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' where products_id="' . zen_get_prid($this->products[$i]['id']) . '" and stock_attributes="' . $stock_attributes_search . '"';
$attribute_stock_available = $db->Execute($get_quantity_query);
$attribute_stock_left = $attribute_stock_available->fields['quantity'] - $this->products[$i]['qty'];
$attribute_update_query = 'update ' . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . ' set quantity='.$attribute_stock_left.' where products_id="' . zen_get_prid($this->products[$i]['id']) . '" and stock_attributes="' . $stock_attributes_search . '"';
$db->Execute($attribute_update_query);
}
// kuroi: End Stock by Attribute additions
NWCider
I solved this issue on my 1.5.1 cart on a Linux server...and it was addressed in the other thread. I'll try and refresh my memory of it and post.
SBA for 1.5.x http://www.zen-cart.com/showthread.p...-5-0%29/page32
In the mean time, I'm wondering why updates to this mod are here for zencart version 1.5.x?
NWCider - just to follow up, especially if you are new to SBA and 1.5.1 - not sure if this is relevant as it seems this thread has taken over the development of this mod. Here is my post about the issue of sync quantities from that other thread...but, once our site was up and running for a few days on the Linux server the user RoboPhung's version began behaving without issues as long as we had the settings as described here. (Not trying to confuse things further, Just getting in the game, guys, so I can stay in the loop of the newer developments on this valuable zencart need.)
We have mostly non-attribute items up to about 1200 total. About thirty of those have attributes. We have RoboPhungs version installed and are still working on a sync quantities issue; However, everything else seems to be working very well in 1.5.1.
The sync issue for us is currently being solved by just pushing the "sync all quantities" link every day on the Config > SBA page, other wise, customers can check out without the help of a warning, only if the number of product with the chosen attribute is less than the total quantity of the product. Some weirdness that RoboPhung is working on and may just be some install issue on our end.
Check your install, (as if you haven't...but check it again anyways). Also, because single drop down does not work, check that under Config > Stock you are using:
Check stock level true
Product Info Single Attribute - multiple_dropdowns
Product Info Multiple Attribute - sequenced_dropdowns
1.5.1 Questions
What happens when I sync all quantities?
Can I change it so when people DO NOT select an option it prevents from ordering?
Can I change it so when products with attributes but no stock qty, it goes to unlimited?
Bookmarks