I use the latest dev version from 3th of November. I will use a second collection for rent products. For this I create a taxonomy call 'rent_collection' with some terms. This terms should be use in the secondary-menue. I rebuilt the menue and create a clone of the 'Collection Product' view.

The options for the Taxonomy menu in the vocabulary are:
Menu Location = 'Secondary navigation'
Menue Path Type = 'Commerce Kickstart Taxonomy'

After the rebuild of the menu the menue items are not in the Secondary Menue.

When I use:
Menu Location = 'Secondary navigation'
Menue Path Type = 'Default'

The menue items are in the Secondary Menue after the rebuild but the links behind the menu items are not correct.

I think the new approch from https://code.drupalcommerce.org/#/c/487/ is not far enough.

Comments

bojanz’s picture

Priority: Critical » Normal
jsacksick’s picture

I'm pretty sure it doesn't work because of the check we're doing in the uri callback of the taxonomy_term

$uri = 'taxonomy/term/' . $taxonomy_term->tid;
  $machine_names = array(
    'product_category',
    'collection',
  );
  // Alter the default uri for those two vocabularies so that it point to our
  // custom views.
  if (in_array($taxonomy_term->vocabulary_machine_name, $machine_names)) {
    $uri = $taxonomy_term->vocabulary_machine_name . '/' . $taxonomy_term->tid;
  }

If you select commerce kickstart taxonomy, it will try to create a menu item that points to a link like this vocabulary_machine_name/tid, but if you don't alter the uri of the taxonomy_term, this won't work, we could probably remove the vocabulary check here.

uking’s picture

A the moment I have no access to my Environment. I am shure, that I add my vocabulary_machine_name in the array $machine_names with no effects. But I will check this tomorrow evening.

jsacksick’s picture

Status: Active » Fixed

If you want to do that, don't touch the kickstart modules, alter the uri callback like we're doing in kickstart_taxonomy for your own vocabularies this way pathauto will work and it will point to your new view.

uking’s picture

I add the menu items with this option in the taxonomy:

  • Menu Location = 'Secondary navigation'
  • Menue Path Type = 'Default'

With the option:

  • Menue Path Type = 'Commerce Kickstart Taxonomy'

the menu item are not added

For a quick check I change the kickstart module and add the vocabulary_machine_name 'rent_collection'

function commerce_kickstart_taxonomy_term_uri($taxonomy_term) {
  $uri = 'taxonomy/term/' . $taxonomy_term->tid;
  $machine_names = array(
    'product_category',
    'collection',
    'rent_collection',
  );
  
  // Alter the default uri for those two vocabularies so that it point to our
  // custom views.
  if (in_array($taxonomy_term->vocabulary_machine_name, $machine_names)) {
       $uri = $taxonomy_term->vocabulary_machine_name . '/' . $taxonomy_term->tid;
  }
  return array(
    'path' => $uri,
  );
}

Clear the chache,too.

With a print I saw that the $uri is change to 'rent_collection/76'.

The differents between the two views are only:

1,2c1,2
< $view = new view();
< $view->name = 'collection_products';
---
> $view = new view();
> $view->name = 'rent_collection_products';
6c6
< $view->human_name = 'Collection products';
---
> $view->human_name = 'Rent Collection products';
128c128
< $handler->display->display_options['path'] = 'collection/%';
---
> $handler->display->display_options['path'] = 'rent_collection/%';
179c179
< $translatables['collection_products'] = array(
---
> $translatables['rent_collection_products'] = array(

The view 'Rent Collection products' is not shown.
Where can be the problem?

uking’s picture

I had try a new installation based on rc3 and create my own module:

<?php


/**
 * Implements hook_entity_info_alter().
 */
function koenigsohn_taxonomy_entity_info_alter(&$entity_info) {
  // Alter a URI callback to the taxonomy_term entity.
  $entity_info['taxonomy_term']['uri callback'] = 'koenigsohn_taxonomy_term_uri';
}

/**
 * Uri callback for the taxonomy terms.
 */
function koenigsohn_taxonomy_term_uri($taxonomy_term) {
  $uri = 'taxonomy/term/' . $taxonomy_term->tid;
  $machine_names = array(
      'rentcollection',  
  );
  // Alter the default uri for those two vocabularies so that it point to our
  // custom views.
  if (in_array($taxonomy_term->vocabulary_machine_name, $machine_names)) {
    
    $uri = $taxonomy_term->vocabulary_machine_name . '/' . $taxonomy_term->tid;
   
  }
  return array(
    'path' => $uri,
  );
}

Clone a new view "rentcollection" with the path rentcollection/%

The view is not shown. Where can be the problem?

jsacksick’s picture

Well you said your taxonomy vocabulary name is rent_collection but in your uri callback you wrote rentcollection :

/**
* Uri callback for the taxonomy terms.
*/
function koenigsohn_taxonomy_term_uri($taxonomy_term) {
  $uri = 'taxonomy/term/' . $taxonomy_term->tid;
  $machine_names = array(
      'rentcollection', (should be rent_collection)
  );
}

uking’s picture

Status: Fixed » Closed (works as designed)

Many Thanks.

I solved the problem. I have recreate the taxonomy menue after I do the fix in my module. Than I fix my rent_collection_products view. To clone the collection view only is not enough.

Now I have some problem with the theme of the new view. But I assume this is not a bug, thus this bug can be closed.

marktheshark’s picture

Does one need to create their own module to get the Commerce Kickstart Taxonomy menu items to work?

Also, does the Collection Product display view get regenerated once the menu is rebuilt?

I'm trying to create the same Collection-based view as the demo store, but there is no choice for the Indexed Node Collection term in Contextual Filters.

Note that the Collection vocabulary is not in the non-demo store, so I recreated it.

jsacksick’s picture

Are you creating a view based on the product display index ? Because this view is not taxonomy based anymore ?

marktheshark’s picture

I'm just modifying the view that I assume CK has adapted after rebuilding the taxonomy menu (whose items I have selected to go into the main menu).

I have not created any new views, it's one of the built in views (Collection Products).

The page path was automatically set to product_category/% (because I accidentally had added the Product Category taxonomy to the main menu as well, now I have set only the Collection vocabulary). I modified this path to be collection/%.

I'm currently stuck trying to set the contextual filter.

jsacksick’s picture

We're altering the view by code for the "no demo" store but if you've saved the view then it should be read from the database.
Can you tell me if your new collection field is indexed ? (Go to admin/config/search/search_api/index/product_display/fields) and try to search for "Collection".
If it's not checked this is probably because your index is "overriden", if it's not overriden then clearing the cache should fix the issue.
Waiting for your feedbacks.

marktheshark’s picture

OK, so I have to mark the field for indexing, if I understood you correctly.

I will try this as soon as I get home and get back to you.

Could this be preventing the auto-generation of menu entries via Commerce Kickstart Taxonomy?

marktheshark’s picture

OK, we have success. :-)

It was the missing cache refresh + contextual filter in the view that was needed for the menu rebuild to work.

Thanks a lot.

Could you explain the difference between view in code or DB and how it affects this case?

Should I revert it to stock and rebuild the menu again?

Edit: I reverted the view but turns out it was a pretty bad idea... :-(

Will have to re-do the procedure. I don't quite understand why the default view uses some other vocabulary. Unless I am mistaken I created this vocabulary myself as well...

marktheshark’s picture

A minor remaining problem is that currently the menu links point to collection/11, etc. not to collection/shoes. In other words, the tid not the term name.

jsacksick’s picture

You shouldn't have reverted the view as we're altering it by code.

I don't quite understand why the default view uses some other vocabulary

Because we have a code saying "You're in demo mode : pick the collection vocabulary, else take the product category..."
The canonical uri of the taxonomy term is altered, basically what you need to do is to take the inspiration from the commerce_kickstart_taxonomy module, at some point we'll make this configurable.

marktheshark’s picture

Thanks for the explanation.

Do you have a recommendation for making the taxonomy menu links use the term name and not the id?

marktheshark’s picture

Still no progress in making the taxonomy view override the default taxonomy listing.

The menu items point to vocabulary/term-id where the view does work.

I need it to point to vocabulary/term-name and also have the view work there as well. Currently vocabulary/term-id does the default taxonomy listing for me.

This works in the demo store, no idea how to make it work on the non-demo store...

jackdaniel9’s picture

Subscribe.

Did you find a solution ?

With demo product_category Taxonomy... create by Commerce Kickstart Guys -> Build Taxonomy Menu Work and pagination don't work.

With another category Taxonomy ...create by us -> Build Taxonomy Menu Don't Work and pagination Work.

theodorosploumis’s picture

Title: Menue path type with Commerce Kickstart Taxonomy » Menu path type with Commerce Kickstart Taxonomy
Issue summary: View changes