Ok, been playing with the dev version on my test server since we may want to implement this on our live site once it's all in place and I wanted to play with the features that don't already exist in the stable versions.

I have been playing with subproducts because this will be a must for our site, and have been following the instructions here: http://drupal.org/node/202526.

Now a couple of weird thing are happening:

1) When I make a subproduct and attempt to edit the subproduct attributes from the tab, I only get one variation, and under that variation I only get one attribute, regardless of how many were previously entered. Also, this attribute may or may not be an attribute that was actually attributed to that variation...see number 2.

2) When I check all subproduct attributes, using the link, I see all of the variations I created, however, ALL of the attributes, under ALL of those variations are the same.

For instance, I have set up the following:
Variation 1: Color
Attributes: Black, White, Blue

Variation 2: Size
Attributes: Small, Medium, Large

Variation 3: Period (Historical)
Attributes: Elizabethan

All of my attributes show up properly on the "Products" page under the admin links, but the Subproduct Attributes page shows the following:

Variation/Attribute
Color
Small
Size
Small
Small
Period
Small
Small

Any ideas? Or any other information you need?

Comments

dawnhawk’s picture

Title: Subproducts attributes acting oddly » Subproducts attributes acting oddly - Additional Bug

Also, trying to select the erroneous Attribute (on the Subproduct attributes tab of the Subproducts page) which currently looks like this:
Period
[] 0 Small

and clicking submit does not give an error or a success indicator, it just reloads the page without the checkbox checked, which looks like it didn't select, however the subproduct page now shows:

Size
Product Size
__________
0 Small

*very confused*

disasterMonkey’s picture

I've also been looking to get SubProducts working. To date with limited success. Given the noises about an imminent release of eCommerce v4 I thought I'd try and go with that rather than v3 and ec_live_subproducts. Mind you I didn't have much luck with that version either.

SubProducts at the moment seems fairly buggy and unintuitive. Given I have a fair amount of software development experience (especially database) I thought I'd muck in rather than just moan.

Based on the latest CVS release, 24 Jun 08, there seems to be a problem with the SQL query generated by _subproducts_attribute_get in subproducts.inc.
I haven't given any consideration to the cases where ec_sp_bpattribute and ec_sp_pattribute joins are required, so this may not be totally correct.
I have come across other existing bugs since implementing this change that I'll continue to try and track down.

Corrected function is below. Sorry no patch.

/**
* Get all attributes
*
* @param $id
* Number, parent variation ID
* @param $type
* String, the search type
* baseproduct = get all attributes from a given parent subproduct
* product = get all attributes from a given subproduct
* @param $pager
* Number, how many variations show be selected
* @return
* Object, all attributes and theirs fields or null
*/
function _subproducts_attribute_get($id = null, $type = null, $pager = null) {
static $variations = array(); // try to cache the results
if (!isset($variations[$id][$type][$pager])) { // results is cached
$sql_join[] = ' INNER JOIN {term_data} td ON tn.tid = td.tid
INNER JOIN {ec_sp_variation} sv ON sv.tid = td.tid';
$sql_where[] = ' td.vid = %d ';
$sql_args[] = variable_get('ec_sp_taxomony', 0);
if ($type == 'baseproduct' and !empty($id)) {
array_push($sql_join, ' INNER JOIN {ec_sp_bpattribute} a ON a.nid = tn.nid ');
array_push($sql_where, ' AND a.pnid = %d');
array_push($sql_args, $id);
}
elseif ($type == 'product' and !empty($id)) {
array_push($sql_join, ' LEFT JOIN {ec_sp_pattribute} a ON a.nid = tn.nid');
array_push($sql_where, ' AND a.pnid = %d');
array_push($sql_args, $id);
}
$sql_final = 'SELECT n.nid, td.*, sv.* FROM {node} n
INNER JOIN {term_node} tn ON tn.nid = n.nid'. implode('', $sql_join) .
' WHERE '. implode('', $sql_where) .' ORDER BY weight ASC';
$sql_final = db_rewrite_sql($sql_final);
if (empty($pager)) {
$result = db_query($sql_final, $sql_args);
}
else {
$result = pager_query($sql_final, $pager, 0, null, $sql_args);
}
$variations[$id][$type][$pager] = array();
while ($variation = db_fetch_array($result)) {
if (empty($variations[$id][$type][$pager][$variation['tid']])) {
$variations[$id][$type][$pager][$variation['tid']] = $variation;
}
if (!empty($variation['nid'])) {
$variations[$id][$type][$pager][$variation['tid']]['attr'][$variation['nid']] =
node_load($variation['nid']);
}
}
}
return $variations[$id][$type][$pager];
}