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

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.

Status:Active» Fixed

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

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.

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,
  );
}
?>

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.

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

@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.

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).

Yes tried it several times, no success.

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).

Hi Guys...

I feel I am so close to sorting my issue which is very similar to the very first post here!!

I am using D7, and the Kickstart 2.0 distribution (which is awesome!!)

I have 3 vocabularies which are attached to the node...but also have one that is attached to the product (in the form of discounts).

I can get the search blocks for the 3 node based ones set up easily enough. When I try and copy the set up, by adding the 'Product Variations' additional field and then 'Product variations >> Discounts' then I set up the workflow, facets and sorts tabs in the same way as they others, then adding the block from the blocks admin....aaaaaaannnnnndddd....

NOTHING!

Thie first three work great but no discounts filter!! I know I must be so close and it is probably a simple configuration issue.

Commerceguys have recommended a turbo ticket costing me £65.00 to try and assist me....not great for my first attempt at promoting their OPENSOURCE' solution to my client! :(

Can anybody here help me out?

Thanks in advance guys.

p.s just to say that I would happily pay commerce guys in future and no doubt will have to with some of the larger sites I have in the pipeline, I really want to move our ecommerce solution of choice to Commerce instead of Magento moving forward...but need to have these small issues resolved.

..... I think a related issue may also be that the rendered taxonomy term 'Free this month' from the Discounts vocabulary on the node variation doesn't display an results on the taxonomy page view??? Strange...its does it the term is attached to the node??

Despite the title says:
The taxonomy menu should use "vocabulary/term-id" links - this is the real (system path).
The "vocabulary/term-name" paths are actually the path aliases for "vocabulary/term-id" paths.

So here, imho, it is an issue about path alias generation.
So first you should check if you have aliases as:
"your-vocabulary/term-name" for "your-vocabulary/term-id"

examples:
demo

  • collection/carry for collection/9
  • collection/drink for collection/10
  • collection/geek-out for collection/11

or for non-demo

  • product-category/sample-category-1 for product_category/1
  • product-category/sample-category-2 for product_category/2

.

@gibry21, about #12
i strongly believe you have another issue and you should open a new one, instead of using this one. thank you

Yes, manual aliasing is what I ended up doing. Thanks

Non demo store

I am using a vocab called collections and using the code from #1 Also I have collections/[term:name] set for the path alias.

The result when viewed in URL Aliases

Alias -> collections/concept
System -> taxonomy/term/44

The result for the existing vocab Product category

Alias -> product-category/sample-category-1
System -> product_category/1

The result when checked in admin/structure/menu/ -> collections/44

Product category works as expected.

Commerce Kickstart Taxonomy is selected for the vocab although I am using this vocab as a sub menu of the main menu.

I have tried suggestions above to no avail!

Component:Code» Documentation

I just spent 2 days getting this working, and wrote up my notes. Im sharing them here so that the community can correct and improve them for the benefit of others who may be struggling with this.

In a non demo store, everything is set up to work using the Product Category vocabulary to assign products to specific catalog pages, with menu items automatically created in the Main Menu for each term you create in the vocabulary. If you want to use a different Vocabulary (because maybe you don't like "product-category" in your URL's) there are a lot of settings that need to be changed in different places (which I'll go through below), and you also (as J. Sacksick points out above) have to override code in the Commerce Kickstart Taxonomy module which has the machine-name of the Product Category vocabulary hard coded into it.

The easy solution (Caveat: I have not tested the easy solution, as it only occurred to me after I had worked through the hard solution given below)

However, if all you want to do is change how your catalog page urls look, there is an easy solution. Leave everthing as-is, use the Product Category vocabulary to classify your products, and simply edit the path-alias settings for the "Product Category" paths to change the replacement pattern from "product-category/[term:name]" to "another-phrase-you like/[term:name]". This should give you what you want and takes about two seconds. You might have to regenerate the aliases if you already have added terms to the vocabulary before you changed the replacement pattern.

The hard solution - background info

If you are determined to use a completely different vocabulary, and not use the pre-defined Product Category vocabulary, it can be done, but it's a bit more work.

Before going into what must be done, it's useful to first understand the different things that happen to make the catalog page urls work the way they do:

  1. When a term is added to the Product Category vocabulary, it is assigned a custom uri of the format /product-category/TID (terms in all other vocabularies are given uri's in Drupal's standard format of /taxonomy/term/TID). Customization of the uri's is accomplished by the Commerce Kickstart Taxonomy module, which is hard-coded to perform this customization only on terms belonging to the Product Category vocabulary. (This module is located at /profiles/commerce_kickstart/modules/commerce_kickstart/commerce_kickstart_taxonomy.)
  2. At the same time, an aliases is created for the custom uri of format /product-category/TERM-NAME for these uri's. This alias is created in a straight-forward manner using the Pathauto module.
  3. Also, a new menu item is automatically created using the term's name, and the path alias generated in step 2 above. This is accomplished by the Taxonomy Menu module, and (again) the Commerce Kickstart Taxonomy Module which implements hooks provided by Taxonomy Menu in order to add an additional settings option (more on this below).
  4. The content displayed when visiting the custom uri (or its alias), is generated by a view named "Collection Products", which overrides Drupal's standard taxonomy page display . This view has a path of /product-category/%, and a contextual filter based on the Product Category term-reference field present on the display nodes for each product bundle.

The hard solution - Step by step implementation

So, following the same order as above, here are the steps you need to change in order to substitue the Product Category vocabulary with a vocabulary of your choosing:

1. You must either hack the commerce_kickstart_taxonomy.module, or create and enable a module that implements slightly modified versions of the commerce_kickstart_taxonomy_entity_info_alter and commerce_kickstart_taxonomy_term_uri functions found in commerce_kickstart_taxonomy.module. You can use the following code for these two functions, substituting YOUR_MODUL_NAME and YOUR_VOCABULARYS_MACHINE_NAME wherever they appear (the vocabulary machine name can be seen on the edit tab of the vocabulary):

<?php
/**
* Implements hook_entity_info_alter().
*/
function YOUR_MODULE_NAME_entity_info_alter(&$entity_info) {
 
// Alter a URI callback to the taxonomy_term entity.
 
$entity_info['taxonomy_term']['uri callback'] = 'YOUR_MODULE_NAME_taxonomy_term_uri';
}
/**
* Uri callback for the taxonomy terms.
*/
function YOUR_MODULE_NAME_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 == 'YOUR_VOCABULARYS_MACHINE_NAME') {
   
$uri = $taxonomy_term->vocabulary_machine_name . '/' . $taxonomy_term->tid;
  }
  return array(
   
'path' => $uri,
  );
}
?>

2. Go to the path alias settings page (admin/config/search/path/patterns), and in the "Taxonomy term paths" section, look for the text field where you can set the pattern for your vocabulary. There set the patter n you want for the urls of your catalog pages. For example: your-vocabulary-name/[term:name]

3. Edit your vocabulary, and look for the "Taxonomy menu" section of the vocabulary's configuration. Set these as follows - and remember to save your changes:
a. Menu location:
b. Menu path type: Commerce Kickstart Taxonomy (This option is created by the functions commerce_kickstart_taxonomy_taxonomy_menu_path and commerce_kickstart_taxonomy _term_path, both contained within commerce_kickstart_taxonomy.module )
c. Options: The boxes next to "Synchronize changes to this vocabulary" and "Auto expand menu terms" should already be checked, and the rest unchecked. You don't need to check any more boxes (but you can if have a special need to do so.)
d. All the rest of the fields (Custom name for vocabulary item, Display descendents, Use 'All" at the end of URL, and Select to rebuild the menu on submit), can be left empty/unchecked.
4. Edit the "Collection Products" view, and make the following changes:
a. Path: change the path setting to "/your-vocabularys-machine-name/%".
b. Contextual filter: By default, after installing the non-demo store you will have one contextual filter. Delete it and recreate it using the term reference field you used to attach your vocabulary to the product display node bundles you have defined. The settings for the filter should be set as follows:
i. When filter is NOT in the url: Hide view / Page not found (404)
ii. Skip default argument for view URL: leave unchecked
iii. When filter value IS in the url, or a default is provided: Click the box next to "specify validation criteria) then:
1. Set Validator to "Taxonomy term"
2. Under "Vocabularies", check the box for your vocabulary
3. Filter type id: Term ID
4. Transform dashes in URL to spaces in term name filter values: leave unchecked
5. Action to take if filter value does not validate: Hide view/ Page not found (404)
iv. In the "More" section, leave everything empty/unselected.

Troubleshooting:

The main menu only contains "All products" and/or isn't being synchronized with your product vocabulary: This problem can occur if you configure your new vocabulary to synchronize with the main menu, and you start adding new terms BEFORE you have updated the Contextual filter on the "Collection products" view to use this vocabulary. If you realize that you have not updated the Contextual filter as describe above, go ahead and update it, then go to the edit page for your vocabulary, check the box next to "Select to rebuild the menu on submit", then save.

Hi,
Shouldn't the Commerce Kickstart Taxonomy module be changed because it is unwanted to have the machine-name of the Product Category vocabulary hard coded into it?
If that is changed is your _alter still necessary?
Greetings, Martijn

Hi Martijn,

You could fairly easily modify the Commerce Kickstart Taxonomy module to create a setting accessible via the UI that would allow the site administrator to choose the vocabulary being used. That would eliminate the need for the _alter, but not all the other manual changes. Automating those would be more difficult.

Why bother when you can just use the hard-coded vocabulary, and change the path names via path alias?

Hey sja1/Steve,

I was looking for a solution regarding generation of taxonomy menu having path aliases instead of standard taxonomy tag path. Documentation in comment #16 saved me lot of time & effort

Thanks
Siva

Issue summary:View changes

Sja1's comments in #16 were very helpful for I as well. There is still a lot of confusion as to the logic and purpose behind why this route of a custom module was taken by Commerce Kickstart. Not newbie friendly in the least.

Other than renaming the system path and intercepting Drupal 7's default view in order to plug in the Collections view in its place, and the devs needing to enable a choice functionality between demo store-Collections and non-demo store-Product Category is there any other reason why this route was taken?

There appears to be much simpler ways of overriding Drupal 7's default taxanomy term pages, including the Taxanomy View that comes built in with Views. Why go through this trouble? Does it have anything to do with the CK devs not wanting to override Drupal 7's view? Is this considered a preferred method of development since now the vocabulary's system path directly leads to the custom Collection View? Or is this module something we can completely ignore, and use any method to override the views? What other purposes does it have?

Some more documentation on the logic and purpose behind it would be very helpful, especially to new users such as myself.