Download & Extend

Get product type menu items to match content type menu items

Project:Drupal Commerce
Version:7.x-1.x-dev
Component:Product
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:dcsprint3, low-hanging fruit

Issue Summary

Currently, the product types menu item only appears with the "Add product type" menu item as a child item in the Admin Menu. However, the content types menu works well by including the various content types with their own sub-menu items in the Admin Menu. We need them to match. : )

(Unfortunately I can't get a screenshot with Skitch b/c I can't hover on the admin menus while snapping an image...)

Comments

#1

Might want to ask tha_sun whether its a known problem.

#2

Looking at the code, the difference is the menu items for adding products are each defined as MENU_NORMAL_ITEMs through a foreach() whereas the menu items for product types use a %commerce_product_type wildcard replacement on a MENU_CALLBACK item.

#3

My first stab at this is here.

This is the approach that DamZ suggested.

However, it is currently not working:
1) The menu item doesn't appear in the menu (am I missing some param? Tried adding "module", setting it to "system" or "commerce_product", nothing.)
2) When editing a product type it finds an existing $mlid the first time. Trying to edit for a second time (both times no data changed) results in no existing $mild found. No idea why :/

(And yes, the api doc for commerce_product_type_provide_menu_link() needs massaging).

Take a look, let me know your thoughts.

#4

Status:active» fixed

I believe I solved this by implementing hook_admin_menu_map():

<?php
function commerce_product_ui_admin_menu_map() {
 
// Add awareness to the administration menu of the various product types so
  // they are included in the dropdown menu.
 
$map['admin/commerce/products/types/%commerce_product_type'] = array(
   
'parent' => 'admin/commerce/products/types',
   
'arguments' => array(
      array(
'%commerce_product_type' => array_keys(commerce_product_types())),
    ),
  );

  return
$map;
}
?>

http://github.com/rszrama/drupalcommerce/commit/a8fa26fd3349b4152f017984...

#5

Status:fixed» closed (fixed)

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

nobody click here