Hi
I'm looking for a automatic setting of canonical pages.
There is an interesting API function: forseo_page_canonical_or_duplicate
This does not serve this exact purpose, or rather is used later on in the process. Whether a page is canonical or not is identified by 4SEO by computing a "page_id". For instance, if you have 2 URLs to the same Joomla article with id=42:
index.php?option=com_content&view=article&id=42&Itemid=123
and
index.php?option=com_content&view=article&id=42&Itemid=456&catid=3
4SEO knows that for a Joomla article, in that case, Itemid and catid don't matter. It computes the page_id
as option=com_content&view=article&id=42
, and therefore one page will be the canonical and the other a duplicate.
I think the ideal hook to use in your case would rather be: forseo_page_build_content_id.
You use it by:
- creating/opening this file: /libraries/weeblr/forseo_functions.php
- it should start with:
return $id;
}
$view = $pageData->get('view');
$id = $pageData->get('id');
$Itemid = $pageData->get('Itemid');
// extract here other variables from the $pageData object as needed.
// The $id is actually an array of variables.
// To removed something from the id, unset the variable:
if(some_condition) {
unset($id['Itemid'];
}
return $id;
}
);
This is just the basic to get you started. I can't provide custom programming as part of support but hopefully you can make sense of it.
The global idea is that if 2 pages are for the same product, they should have the same page_id. IF you manage that, then 4SEO will take it from there and all the rest will work, including adding the canonical, excluding from the sitemap, etc
So what you need to find is why Phoca cart is having multiple URLs to the same product (a product can be in 2 categories for instance?) and translate that into that page_id.
Note that after you made any change here, you must Reset the analysis so that this new function is taken into account.
Best regards
Yannick Gaultier
weeblr.com / @weeblr