Download & Extend

Empty attribute option select lists in catalog grid view

Project:UC Attribute Stock Filter
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:henrrrik
Status:closed (fixed)

Issue Summary

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.

AttachmentSize
uc_attribute_stock_filter.module.patch4.39 KB
uc_attribute_stock_filter.js_.patch1.38 KB

Comments

#1

Assigned to:Anonymous» henrrrik

#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.

AttachmentSize
uc_attribute_stock_filter.module.patch 4.46 KB

#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

AttachmentSize
uc_attribute_stock_filter.module.patch 6.68 KB

#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 :)

#8

I found this same bug, and same solution. Why is this still unpatched, almost three months after it was confirmed?

AttachmentSize
uc_attribute_stock_filter.module.patch 850 bytes

#9

how do i add the patches to my uc_attribute_stock_filter module? sorry to ask such a stupid question but I new at this!

#10

I just found that if you have added a SKU to an attribute, but NOT enabled stock tracking for the attribute - it's now shown in the select box either. You'd need to have a seperate SKU for item+attributes f.ex. for recurring feature for an attribute.

I fixed this - and have added all the above patches as well in the patch I've attached here. The patch is done against beta12.

you have to have a seperate sku to EVERY attribute (if you have any seperate SKU's), AND you have to enter the stock count page and "save" that page after adding the SKU's - otherwise the way this module works now - it will only show the attributes which actually have a seperate sku stock-level saved.

p.s. To the current maintainer of this module: I'll gladly co-maintain (or just takeover maintainance) and release a beta13 - and make new releases as patches show up from me or others as needed.

p.p.s. This patch can be applied (under unix/linux) by standing in the uc_attribute_stock_filter module folder, with the patch in same folder, and running: cat *.patch | patch -p0

AttachmentSize
uc_attribute_stock_filter.patch 9.86 KB

#11

Status:needs review» closed (fixed)

I belive this issue to be fixed with release of 1.0-beta13 as of today.

I tried to implement the patches as possible, and several additional fixes of my own - I hope I didn't miss something.

I haven't added the patch to exclude JS when no attributes have stock control. I'll have to have a closer look at what it actually did, and implement it later on if it's something that really has a usecase.

I hope you will test this release and report any mishaps - it works for me, and I tried to test all cases.