Hello!
I found, that "node/add/add-product" menu item has "_node_add_access" access callback. It means, that this menu item will be available if user can create nodes of any type, for example, articles (even user can only create non-product nodes).
There is the screenshot: http://i.imgur.com/PglemZw.jpg

If user will click on this menu item, node_add_page page callback will redirect him to page of other content type node or will show him the list of content types - so we need just add an access callback to hide "add-product" menu item from admin menu.

So, I suggest to add an access callback which will be check only product nodes creation access.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Evgeny_Yudkin created an issue. See original summary.

Evgeny_Yudkin’s picture

Evgeny_Yudkin’s picture

Status: Active » Needs review
Evgeny_Yudkin’s picture

FileSize
2.13 KB

Added codestyle fixes

Evgeny_Yudkin’s picture

Issue summary: View changes
mglaman’s picture

Issue tags: +commerce-sprint
jantoine’s picture

Assigned: Evgeny_Yudkin » Unassigned
Status: Needs review » Reviewed & tested by the community
FileSize
1.42 KB

The attached patch, for whatever reason, removes some lines and then adds the exact same lines back in. There are also Drupal coding issues and changes unrelated to the fix. Attached is a cleaned up patch that fixes these issues.

Since this patch has absolutely no functional changes and the patch works, I'm marking this as RTBC.

mglaman’s picture

+++ b/commerce_backoffice_product.module
@@ -475,3 +476,20 @@ function _commerce_backoffice_product_display_vocabularies() {
+    if (node_hook($type->type, 'form') && node_access('create', $type->type)) {

Couldn't we just invoke _node_add_access here?

Also, thanks for patch without code styling fixes. Makes it much easier to review.

fox mulder’s picture

#7 resolves the problem for me

jantoine’s picture

@mglaman,

No, we can't just invoke _node_add_access because it does not take a bundle parameter and will return TRUE if the user has access to adding, say, an 'article' bundle. Invoking _node_add_access here produce the same result as using it as the 'access callback' parameter, displaying the top menu item when a user doesn't have access to add a product display type.

mglaman’s picture

Cool. We don't have tests enabled here (wink wink, hint hint for anyone wanting to step up.) So I'm running a test on CK2's behat test suite with this patch: https://travis-ci.org/mglaman/commerce_kickstart/builds/138525887.

If that's green I'll commit.

Thanks everyone!

Evgeny_Yudkin’s picture

@mglaman,
As I see, build is green (excepting php7 and hhvm jobs).

  • mglaman committed 6154c1c on 7.x-1.x authored by jantoine
    Issue #2694721 by Evgeny_Yudkin, jantoine, mglaman: node/add/add-product...
mglaman’s picture

Status: Reviewed & tested by the community » Fixed

Fixed! Sorry, I've been tied up with client work and 2.x :) Meant to commit earlier.

Evgeny_Yudkin’s picture

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.