| Project: | UC Attribute Stock Filter |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | henrrrik |
| Status: | needs review |
Using the latest dev version, I found that all options (other than "Please select" for required attributes) were being removed from the option select lists in the catalog grid view. This didn't occur on product pages. I found a simple fix for that, but once the options were displayed on the catalog page, I observed that the stock filtering wasn't working. It appeared that the design hadn't allowed for more than one add-to-cart form to be handled per page. I modified the PHP and JavaScript to support multiple forms, though the solution is sub-optimal: when a catalog page loads, the JS allowable combinations array is redefined in the output for each product. The result appears to work fine, however.
#1
#2
Here's a small update to the PHP patch submitted earlier. This version will suppress the inclusion of the JS allowable combinations array in the output when the attributes option is disabled in the catalog grid view, allowing the page to load a bit faster. The previous JS patch is still required.
#3
Great! I'm going to give the module a quick overhaul and incorporate your improvements soon.
#4
This patched worked for us against the latest Dev. Kind of a serious issue (and strange, since the Select form works fine in the "Catalog" but not in any View.
+1 to get these changes committed!
#5
I patched 6.x-1.0-beta12 (cause that is what i had installed) with this and it works great for products that are displayed in a View.
Thanks...
#6
I found that products with no attributes and which are not under stock control would be handled as if they were under stock control. This always shows the item as out of stock.
The attached patch incorporates the two patches contributed above by jerry. You will still need to use jerry's JS patch.
Cheers
#7
Sounds like I have a similar bug - but not 100% sure (my first Drupal bug report, let me know if you want me to file this under a new report).
Using latest dev version.
Steps to get the bug:
1. Ensure ubercart is setup to show products and have add to cart form on grid listing
2. Create a product with an attribute and more than one option
3. Ensure that more than one of those options is in stock
Expected outcome:
The product is listed with the in-stock options available from the attributes drop-down.
Actual outcome:
The attributes drop-down does not have any options - it comes out as a blank select list.
I tracked down what is causing this bug on my installation of drupal, to uc_attribute_stock_filter.module line 98.
<?php$result = db_query("SELECT a.combination AS combination, s.stock AS stock FROM {uc_product_adjustments} a, {uc_product_stock} s WHERE a.nid = %d AND s.sku = a.model AND s.active = 1", arg(1));
?>
In this query arg(1) is meant to return the nid of the product, and it does when you are on the product detail page. But when on the product listing page, arg(1) returns the term id of the product category instead.
So I guess the solution would be to get the node id from a more consistent source. I fixed it by altering the query so that the nid is taken from the form variable instead. E.g.
<?php$result = db_query("SELECT a.combination AS combination, s.stock AS stock FROM {uc_product_adjustments} a, {uc_product_stock} s WHERE a.nid = %d AND s.sku = a.model AND s.active = 1", $form['nid']['#value']);
?>
Works for me, hopefully it'll work for someone else also :)