Download & Extend

Commerce Kickstart taxonomy menu generates links towards vocabulary/term-id instead of vocabulary/term-name

Project:Commerce Kickstart
Version:7.x-2.0
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hello and Happy New Year!

I'm following the demo site example on a non-demo installation.

The product list view that is used instead of the taxonomy listing is based on the "Collection" vocabulary and is identical to the demo case.

While CK taxonomy does populate the main menu as I have set it to, the links created are of form collection/9 not collection/shoes, etc.

I would like to avoid this since it is not optimal for SEO.

Note also that while for the demo store the links collection/term-id and collection/term-name point to the same view, on my installation using collection/term-name gets me to the taxonomy/term/% default listing of nodes tagged with this term.

Am I missing some configuration setting? Thank you in advance.

Comments

#1

So you recreated a collection vocabulary on the no demo store, it doesn't work oob by default, you have to update multiple things.
You need to create your own module that take his inspiration from commerce_kickstart_taxonomy (Something like that) :

<?php
/**
* Implements hook_entity_info_alter().
*/
function your_module_entity_info_alter(&$entity_info) {
 
// Alter a URI callback to the taxonomy_term entity.
 
$entity_info['taxonomy_term']['uri callback'] = 'your_module_taxonomy_term_uri';
}

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

You need to update your vocabulary and tell taxonomy menu to use Commerce Kickstart Taxonomy as menu path type.
Finally, you'll need to override the view and update the contextual filter etc.

#2

Status:active» fixed

#3

Is this the recommended approach for replicating the demo store functionality, or will Kickstart be enhanced to support this for custom vocabularies in the future?

Thank you

#4

This is the recommend approach for now, we'll probably try to find a better solution in the feature but this isn't planned yet.

#5

I've created the following module and placed it under sites/all/modules, still the links of the main menu result in /collection/4.
I tried too do all the steps described above, rebuilding menu..

Here is my module(used your code):

<?php
/**
* Implements hook_entity_info_alter().
*/
function ck_menu_custom_entity_info_alter(&$entity_info) {
 
// Alter a URI callback to the taxonomy_term entity.
 
$entity_info['taxonomy_term']['uri callback'] = 'ck_menu_custom_taxonomy_term_uri';
}

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

#6

Status:fixed» active

I've checked it now with a fresh site. Had the same issue that the created menu only links to the term-id not to the term-name.
Is there anything I can check to see if the module I've created is faulty/not loaded?
Tried to look with devel->entity info and saw uri call from commerce kickstart taxonomy, but I couldn't find any uri call form my module.

#7

@Dubpal: keep in mind that you'll have to generate the aliases with pathauto, did you try that ?

#8

@jsacksick Thanks for your answer. I've regenerated the links via: admin/config/search/path/update_bulk
Also I cleared the cache and rebuild the menu, still the menu-links are pointing to the term-id.

#9

Are you really sure that your vocabulary is set up to use the commerce kickstart taxonomy menu path type? (This setting can be changed when editing your taxonomy vocabulary).

#10

Yes tried it several times, no success.

#11

Can confirm same issue here. Subscribing

Correction. I can now create the correct URL links, however the view is not rendering the expected results (no results whatsoever).

nobody click here