The Problem
After enabling Product API on a Drupal 5.1 system, any time you hit the "Preview" button when creating or editing a non-product node (such as a Page), no preview will appear. You can test this by examining a fresh Drupal installation vs. one with Product API enabled. In the fresh install, 1) create a Page content item and hit "Preview" to preview it; above the node editing form the preview appears. Then enable Product API module and repeat the exact same steps. There is NO preview above the node editing form. Node preview has now vanished entirely from Drupal! (Except for product nodes.)
I tracked down the problem and have a suggested solution. Forgive me for not having an actual patch, but I'm new to patches and haven't gotten the hang of them yet.
The Diagnosis
In modules/node/node.module you will find the following on line 2067 (in the node_form function declaration):
$form['#after_build'] = array('node_form_add_preview');
As you can see from the Drupal Forms API Topic on #after_build, this line of code defines an array of functions to call to do any special processing on the form. (Though the array is only one item long.) If you're curious and dig deeper into node.module, you'll see that the _product_transform_skip_validation function is what prefixes the node preview to any node being edited.
But in modules/ecommerce/product/product.module, you will find the following contradictory code on line 443 (in the product_form_alter function declaration):
$form['#after_build'] = array('_product_transform_skip_validation');
As you can see, it supersedes the existing code, removing the node preview.
The Suggested Solution
My suggested solution (which worked for me) is to replace line 443 with:
$form['#after_build'] = isset($form['#after_build'])? array_merge($form['#after_build'],array('_product_transform_skip_validation')) : array('_product_transform_skip_validation');
Now the existing function rolls the ecommerce form processing function into whatever other processing functions have been defined (by node.module or any other modules), and adds it to the end of the list, so to speak.
I have not tested this fix under a variety of different configurations, so I don't know whether this will introduce other conflicts; I leave that to the Ecommerce module gurus. I hope at the very least it suggests a remedy.
Comments
Comment #1
gordon commentedThis is a duplicate of #126824
Resolved in 3-dev and 4-dev. See http://cvs.drupal.org/viewcvs/drupal/contributions/modules/ecommerce/pro...