Description
This module makes it easy for a Commerce administrator to see which node or nodes display a particular Commerce product.
The module appends a new property to the Commerce Product entity that lists the IDs of nodes that are configured to reference the product, alters the default Commerce module 'Products' view (admin/structure/views/view/commerce_products/edit), adding the new field, and also adds a fieldset listing links to any product display node(s) to the product edit page (admin/commerce/products/<product_id>).
As the Commerce administrator reconfigures their products, product reference fields and bundles, the module will update itself to keep track of these changes meaning the only configuration required by the user is to decide where the information this module makes available, is displayed.
Screen shots are available on the project page.
Project page
https://drupal.org/sandbox/alex_sansom/2143063
Git repository
git clone http://git.drupal.org/sandbox/alex_sansom/2143063.git commerce_prodnodelink
Reviews to other project applications
[D7] Commerce BluePay Hosted Forms
[D7] Commerce Checkout Register
[D7]commerce_intuit
Comments
Comment #1
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxalex_sansom2143063git
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #2
alex_sansom commentedFixed issue with PAReview complaining about missing
t()for config form #options.The remaining PAReview warnings seem, to me, to conflict with how Views field handler classes are coded. PARreview says:
But, looking at the way the Views module implements its classes, which is the style I've used, it's not the same as PAReview recommends.
Is anyone able to confirm which is the correct style? I couldn't find a definitive document.
Comment #3
alex_sansom commentedComment #4
alex_sansom commentedComment #5
candotri commentedI have limited experience with Views but from a general standpoint this code is easy to read, well documented, and flows nicely.
I noticed that other implementations of hook_entity_property_info_alter ( for example, entity/modules/node.info.inc) translate 'description' and 'label'). entity.api.php provides guidance and includes a flag 'translatable' but it's not clear how they intend this to be used. I think i'd t() those to be consistent unless I'm wrong on my interpretation. This is super picky but if you feel strongly you can set the 'translatable' flag to be perfectly clear.
Some reviewers prefer that the .module file is as small as possible. If possible, move functions out into an .inc. It's already quite small so I'd think the performance benefit would be small.
hook_uninstall should call variable_del() rather than manually manipulating 'variable' with sql. This is, in fact, illustrated in the api documentation for hook_uninstall. I like the watchdog message following the deletes.
Good work!
Comment #6
alex_sansom commentedThanks for the review Candotri, much appreciated!
With regards to your comments, I've:
Added the missing t() to the 'label' and 'description' array key values in the hook_entity_property_info alter implementation. I can see that many of the core Commerce modules (commerce_cart, commerce_order_ui etc) do this. They also do not provide the 'translatable' flag you've mentioned. I'm as unsure as you about how that should be used too. For now at least, I'll leave that off.
I can appreciate the point of view about making the module file as small as possible, therefore I've implemented hook_hook_info() and moved the feld related hook implementations into their own *.field.inc file. Probably only a small potential gain, as you say, but it can't hurt.
I've also updated the hook_uninstall() code to use variable_del() too.
Again, thanks for taking the time to review and your suggestions.
Comment #7
klausimanual review:
But otherwise this looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Assigning to stBorchert as he might have time to take a final look at this.
Comment #8
alex_sansom commentedThanks for taking time to look and comment on this project Klausi.
I've made a few more commits to address some of the points you've made above.
I think you're right. I've updated the .info file dependencies to 'commerce_product'. That, indirectly, means there is a requirement of 'commerce' too.
Thanks for the documentation link. It mentions: "When adding a node listing to your module, be sure to use a dynamic query created by db_select() and add a tag of "node_access".". So I've now done that.
If I'm just adding to the form array, I have to add it as a 'type' of form control, currently markup. If I do not call theme() here, the array is never rendered ('Array' is output to the page). Looking at the other available form item types, none appear to be output (like 'markup'), they're input controls such as radios or selects, hence I'm generating the markup and then adding it to the form.
I think I may be misunderstanding what you mean here? If I am, could you expand on what you mean, please?
After reading the 'Node access rights' link you posted, as mentioned, I've added the 'node_access' tag to the query in commerce_prodnodelink_product_display_node_ids(). Hopefully that addresses this, if I choose to display the node title in a future change.
Good point, thanks. I've updated this to use strpos(). Testing this also lead to me fixing a small bug on bundle deletion, cheers!
Comment #9
klausino objections for more than a week, so ...
Thanks for your contribution, alex_sansom!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #10
alex_sansom commentedCool! Thanks very much Klausi and also candotri for all your help.