I've updated the gordon's patch to work with the HEAD branch of the e-commerce module. I'm working to update nedjo's subproducts (the subproducts generation wizard and the "add to cart" functionality are done and tested) and apparel (100% done, I think) modules to help test this patch. I hope didn't made duplicated work.

Comments

recidive’s picture

StatusFileSize
new12.29 KB

I missed the table definition stuff.

nedjo’s picture

Thanks for digging into this!

I'm also working this week on completing the subproducts integration into 4.7/HEAD. Let's coordinate so we can take on distinct parts. There are a few changes we need to make to Gordon's patch (rename parent field to pparent to avoid conflict with book module, drop children field and instead dynamically load the ->children array, etc.)

Maybe I should take on Gordon's patch from where you've taken it, and you could focus on an upgrade to subproducts.module. Does that make sense?

recidive’s picture

StatusFileSize
new8.31 KB

Changed parent to pparent and added the dynamically load of the children array. Some test is still nedded, but I think that we are almost there. This patch was made to work with Nedjo's subproducts.module that for the time being lives in his sandbox.

nedjo’s picture

Thanks recidive. I've moved the (not yet finalized, but getting there) subproducts module to the main ecommerce directory. I'll test and report back on this latest patch.

One question is, should we be moving everything we can to subproducts.module? I.e., should we be limiting the changes to product.module to the absolute minimum, and do everything else in subproducts.module?

nedjo’s picture

StatusFileSize
new2.97 KB

I'm working on stripping down this patch to the absolute minimum and doing everything else in subproducts.module. Recidive and I have been updating subproducts.module to 4.7 (it was initially written for 4.6, sponsored by GoodStorm). It's not done yet, but can be used for basic testing. We've also added HEAD/4.7 versions of two GoodStorm-sponsored modules to the /contrib directory that use subproducts: apparel.module and custom.module.

Attached is an interim version of the enabling patch. It's not ready to apply yet as we need to do more testing.

Note re changes from the previous patch draft:

I've removed the proposed subproduct-specific cart call, and instead changed cart_get_items() to use $node->nid rather than $nid. The idea is that, when needed, subproducts.module can reset the object reference from the parent to the child product.

I've drafted a documentation page on subproducts, http://drupal.org/node/52743, and will add a developer version as soon as I get a chance.

gordon’s picture

Is this the full patch, It doesn't look like much. If it is please commit it.

recidive’s picture

StatusFileSize
new5.81 KB

I've just updated the patch to reflect recent updates in ecommerce package and to add the table definition (tested) and the update (not tested) stuffs. In my view it is ready to be commited.

nedjo’s picture

I want to have a fully tested and working version of subproducts module before applying this patch, as likely completing the subproducts module updates will require more adjustments to the patch.

The update function should go in product module rather than store. Probably we should we remove the pparent field from the CREATE TABLE call in product.install and instead put the _update function.

gordon’s picture

The update function should go in product module rather than store. Probably we should we remove the pparent field from the CREATE TABLE call in product.install and instead put the _update function.

This should be there for new installations, but there also needs to be a product_update_{n}() which includes the creation of the pparent field for existing ecommerce installations.

recidive’s picture

StatusFileSize
new6.1 KB

Changed module_invoke to product_invoke_productapi so the $node really goes as reference and put update function in the right place.

ob3ron’s picture

Are there plans to add subproduct functionality to other product types as well? I'm setting up a site that sells retreats and has different accommodation options (ie a non-shippable product) -- it would be great to be able to be able to set this up within the e-commerce framework, and it's hard to shoe-horn it in currently.

If I can help with the coding, I'd be happy to -- I'm not that familiar with the Drupal codebase yet, but I'm a fairly decent PHP programmer.

recidive’s picture

StatusFileSize
new7.86 KB

Updated patch. Solved some conflicts with lastest changes in ecommerce package. Added index for pparent field to improve performance and now the link for a subproduct in the cart points to its parent product.

Are there plans to add subproduct functionality to other product types as well? I'm setting up a site that sells retreats and has different accommodation options (ie a non-shippable product) -- it would be great to be able to be able to set this up within the e-commerce framework, and it's hard to shoe-horn it in currently.

Yes, We are working to put the stock feature optional by checking if the product return "is_shippable" through the productapi. Currently there are two modules that implements subproducts functionality: apparel (variation-type) and custom (base-type) both generate shippable products because they extends tangible product type. You can start making your own retreats module/product type that will implement variation-type subproducts, I guess.

If I can help with the coding, I'd be happy to -- I'm not that familiar with the Drupal codebase yet, but I'm a fairly decent PHP programmer.

Cool, you can start by testing this and sending your patches :)

gordon’s picture

I was just about to commit this patch, and I found that the call to the product_invoke_productapi() in the cart_add_item() is actually returning an array of falses, because product_invoke_productapi() calls all hook_productapi() and merges all the results togethers.

What is meant to happen is that the invoke should just return 1 value which is false to stop the addition to the cart or anything else which is treated as true, and it can be added to the cart.

Is there a reason for the change, or can I just turn this back to the original module_invoke().

Once I have this sorted I will be commiting this.

gordon’s picture

Priority: Normal » Critical
Status: Needs review » Needs work

forgot to change the status's

recidive’s picture

StatusFileSize
new4.88 KB

Is there a reason for the change, or can I just turn this back to the original module_invoke().

The reason is that we need to pass $node as reference to the productapi so we can reset the $node object reference from the parent to the child product. It's seems not to work with module_invoke because $node goes as a copy instead of a reference. There is another way for doing this?

recidive’s picture

I've found an another way for doing the cart stuff. Please wait, I will send an updated patch as soon as possible.

recidive’s picture

Assigned: Unassigned » recidive
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new6.65 KB

Done. Just removed the changes in cart_add_item(). Now the "add to cart" functionality for subproducts is handled by subproducts_cart_add_item().

gordon’s picture

Status: Reviewed & tested by the community » Needs work

I do not like this idea, Lets change the cart_add_item() so that it calls the productapi direct without using the module_invoke(), this will be a lot cleaner and be easier to maintain.

recidive’s picture

Status: Needs work » Needs review
StatusFileSize
new8.4 KB

Ok, I've put back the cart_add_item() changes in cart.module and 'cart add item' operations in apparel.module and custom.module productapi. Also removed 'subproducts/cart' stuff from subproducts.module.

gordon’s picture

Status: Needs review » Fixed

Thanks for this I have commited it to cvs.

hadishon’s picture

Thanks for the good work!

This handbook page may need to be updated now:
http://drupal.org/node/52743

hadishon’s picture

Status: Fixed » Active

I've been testing the new changes. It seems to work well until I try to edit a product that has variations. When I edit the item and click submit, I get the following errors:

Warning: Duplicate entry '386' for key 2 query: INSERT INTO ec_product (nid, vid, pparent, sku, price, is_recurring, price_interval, price_unit, price_cycle, auto_charge, ptype, hide_cart_link) VALUES('386', '573', '0', '6', '15.00', '0', '0', '', '0', '0', 'apparel', '0') in /httpdocs/includes/database.mysql.inc on line 120

Warning: Cannot modify header information - headers already sent by (output started at /httpdocs/includes/database.mysql.inc:120) in /httpdocs/includes/common.inc on line 233

Once this happens, the page gets "lost" and is dramatically changed. The only way I can get it back is to recreate the node from scratch.

hadishon’s picture

After some more testing, this only happens when "Create New Revision" is selected. As long as you're not making a new revision, it seems to work fine to edit product nodes.

I'm using 4.7 rc2 and cvs (current as of today) ecommerce.module.

gordon’s picture

You most likely had a problem with the upgrade and the index on nid has not been removed. This has nothing to do with the subproducts.

gordon’s picture

Status: Active » Fixed

this is fixed again.

Anonymous’s picture

Status: Fixed » Closed (fixed)