Hi all,

The Ubercart catalog uses an extra path and alias for it's catalog pages. Extremely useful modules like XML sitemap have difficulties finding those paths and aliases and use the obsolete (in my case anyway) standard term pages. hook_term_path() can change that easily. Could this be implemented in a next release or should this also be in a contrib?

function uc_catalog_term_path($term) {
  // $term looks like it doesn't have a $term->name
  $term = taxonomy_get_term($term->tid);
  return uc_catalog_path($term);
}

with big thanks to Kiam.
http://drupal.org/node/425068

Thanks
Mark

Comments

splash112’s picture

Sorry,

It works, expcept if a term is updated. Then it will insert a category/catalog/etc in the Ubercart catalog menu...

grrr

rszrama’s picture

So... is your patch necessary or not?

splash112’s picture

Hi Ryan,

Necessary maybe, but for now incomplete.
It messes up the Ubercart catalog menu on updates (and probably inserts).

Need to dig a little deeper in the code. Probably has something to do with the double paths used in the catlog module instead of changing one.

Mark

rszrama’s picture

Status: Active » Postponed (maintainer needs more info)

Alrighty. I don't like the title of the "needs more info" status, because I'm not just sidelining your request, but I want it to indicate that research is still in progress. : )

heyyo’s picture

Version: 5.x-1.7 » 6.x-2.x-dev

Anything new on this issue ?

I really would like to include the catalog terms in my sitemap.xml and not the taxonomy terms

splash112’s picture

Sadly, not to my knowledge.

The term paths are easily disabled though, through the vocabulary settings.

Another way could be to use views instead of the uc_catalog module.

sean-gnu’s picture

StatusFileSize
new23.38 KB

Hi

Here is a modified uc_catalog to address this issue.

I've removed all path_alias hooks and function calls and hooked into taxonomy_term_path rather.

Path_auto no longer duplicates links (i.e. no more taxonomy/term/% and catalog/% - only catalog/%)

XML sitemap now appears to work as expected.

Some modules with hard-coded taxonomy/term/% paths instead of taxonomy_term_path calls will still not work.

Check your vocab table that the module field is set to uc_catolog.

As per usual it requires further testing !!!

I hope someone finds it useful ...

S.

splash112’s picture

Nice!
Will try and test it soon!

tr’s picture

Status: Postponed (maintainer needs more info) » Needs work

@sean-gnu: Could you please post a patch? Zipping up the entire module is not useful at all, as it is an unknown version of uc_catalog containing unknown and undocumented changes and possibly leaving out fixes that have been added since you downloaded your copy of uc_catalog. More to the point, without a patch there's no way to evaluate your contribution and get it included into the next version of Ubercart.

sean-gnu’s picture

StatusFileSize
new14.55 KB

@TR - sorry - never used patch files before. Good time to start !
Here is the patch file ...

tr’s picture

Good start. I haven't evaluated the patch yet, but one thing in there caught my eye - your correction of a misspelling 'catlaog' in an update function. For future reference, update functions shouldn't be changed. The correct way to fix this mistake is to add a new update function. The reason for that is to make sure that all people who have run update_5(), for instance, end up with the exact same changes to their database. I took the liberty of committing a fix for this in the -dev version of Ubercart.

sean-gnu’s picture

Hi - thanks for the pointers on the update functions and for committing the fix for that in the correct place.

Regarding update scripts :
I think for this patch an update script may need to be created to force the field 'module' in the vocabulary table to be 'uc_catalog'. I have modded the install and uninstall to accommodate this, but for someone upgrading it can potentially slip past. There will probably also need a check in the admin page when selecting the vocab to use for the catalog.
I will look into this if the patch looks good.
For now anyone trying this patch may need to manually check the value of that field using phpmyadmin etc.

fuerst’s picture

Status: Needs work » Needs review
StatusFileSize
new416 bytes

The patch in #10 does much more than this issue was created for. Shouldn't be another issue created for this?

Anyway, here is a patch which just adds the missing hook_term_path() to uc_catalog. This makes modules like http://drupal.org/project/edit_term to be useful for the Ubercart Catalog terms. The missing $term->name as mentioned in the original issue posting is not needed as far as I can see therefor I did not include a call to taxonomy_get_term().

Hopefully that patch get included into the next release since it makes living of Ubercart product managers easier.

fuerst’s picture

Version: 6.x-2.x-dev » 6.x-2.6
StatusFileSize
new419 bytes

Patch still necessary in 2.6

Status: Needs review » Needs work

The last submitted patch, ubercart-425984-14.patch, failed testing.

fuerst’s picture

Status: Needs work » Needs review

#15: Looks like an error in the test bot: First attempty to apply the patch file using -p1 failed, second attempt using -p0 succeeded with status = 0. Nevertheless PIFR thinks it Encountered error on [apply]. Filed it in the issue queue, see #1246354: Test failed with "Unable to apply patch"

fuerst’s picture

StatusFileSize
new446 bytes

Aha - PIFR does not longer accept -p0. Recreated patch with -p1.

fuerst’s picture

StatusFileSize
new446 bytes

Aha - PIFR does not longer accept -p0. Recreated patch with -p1.

Status: Needs review » Needs work

The last submitted patch, ubercart-425984-17.patch, failed testing.

fuerst’s picture

Status: Needs work » Needs review

SimpleTest failed which seems not to be connected to the patch.

longwave’s picture

Testbot cannot currently handle dependencies, but Token is a required dependency in Ubercart 6.x-2.x, so all tests on that branch will fail :(

tr’s picture

Version: 6.x-2.6 » 6.x-2.x-dev

Should be done in D7 too. hook_term_path() has been removed in D7 and replaced by hook_url_outbound_alter(). See http://drupal.org/update/modules/6/7#hook_url_outbound_alter for usage example.

tr’s picture

Now that the testbot is finally working, let's try it again!

#18: ubercart-425984-17.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, ubercart-425984-17.patch, failed testing.

dimitriseng’s picture

I would be great to get this in D7, any plans for this to happen? Thanks.

dimitriseng’s picture

Hi, just checking if there is any progress in getting this in D7... Thank you!!

longwave’s picture

longwave’s picture

Component: Code » Catalog
Status: Needs work » Needs review
StatusFileSize
new447 bytes

Not sure this is worth changing now in 6.x, and should be solved in 7.x by #1909542: Replace hook_link_alter with hook_preprocess_link, but I also don't see why the patch in #18 doesn't apply, so let's see what testbot thinks of this.

longwave’s picture

Status: Needs review » Closed (won't fix)

Looking at it again, I think this is now won't fix for 6.x, as we risk breaking too many existing sites versus any minor benefit that this gives. The patch above will still work if anyone needs this.

agittins’s picture

Not sure if I am understanding this at it's full depth but for the record I think I've worked around this issue. The main bits for me was that xmlsitemap was pointing at the catalog via taxonomy paths instead of at the uc_catalog view, and also that it listed categories in the sitemap which had no products. To fix this:

  • Via xmlsitemap settings, Taxonomy, Catalog:
  • - xml sitemap: excluded
  • - taxonomy_menu, choose "Custom path", set "Base Path for Custom Path" to just "catalog" (so /taxonomy/%tid instead goes to /catalog/%tid)
  • - tick "Hide empty items" (otherwise you'll get soft-404 problems from google)
  • Via xmlsitemap setttings, Menu_link, Catalog:
  • - xml sitemap: included

It seems counter-intuitive, but the idea is that taxonomy links get pointed into the uc_catalog but we don't list them in the sitemap because it will include empty ones. Then we use taxonomy_menu to publish those links into xmlsitemap but without the empties.

It is definitely a bit of a kludge, but that's the thing with uc building a non-drupal menu for navigation I guess. As it happens I have also hacked taxonomy and uc_catalog to return actual 404 responses for empty terms to stop google complaining about (and indexing) the ones that do show up.