Get the Itemid
- jameswadsworth
-
Topic Author
- Offline
I am building a product scroller for hikashop. Everything is working correctly except the breadcrumb when we view the product. At the moment the scroller works with only category at a time. Currently when you click on the link to view a product we get the following breadcrumb
Home > product category > Category A > Category B > Category C > Product Name
I don't want 'product category' to appear. We want the breadcrumb to be:
Home > Category A > Category B > Category C > Product Name
To do so we need the Itemid value for Category A in the URL. Correct? Does Hikashop already have a function that allows you to obtain this value? Thanks
Please Log in or Create an account to join the conversation.
That's correct.
There is no function for that. What we do is that we usually have an option with the user can select the menu to use so that we can properly fill the Itemid parameter of the URLs. You can see that in the modules's hikashop options and the search plugin.
If you want to get automatically the Itemid based on a category you need to have something like that (not tested):
Please Log in or Create an account to join the conversation.
- jameswadsworth
-
Topic Author
- Offline
However I would like to add. The Itemid parameter of the URLs that you can add in the product search plugin only works if all product categories share a common parent menu item. What do you do if you you don't follow this structure?
Please Log in or Create an account to join the conversation.
Concerning the search plugin that is indeed the case. You can always create a specific menu which is not displayed on your template with the main "product category" category as parent category and use that menu in the plugin
Please Log in or Create an account to join the conversation.
- jameswadsworth
-
Topic Author
- Offline
In line 132 we modified the line to:
Then after line 187 - foreach ( $rows as $k => $row ) {
we put the function getItemidFromCategory($category_id) at end. Comments welcome
Please Log in or Create an account to join the conversation.
The , b.category_id as category_id code should not be added in the $select variable but directly in the query:
$query = ' SELECT '.$select.', b.category_id as category_id FROM '.hikashop::table('product') . ' AS a '.$leftjoin.' WHERE '.implode(' AND ',$filters).' ORDER BY '.$order;
Otherwise, it will break the query:
$query = ' SELECT DISTINCT '.$select.' FROM '.hikashop::table('jf_content',false) . ' AS b LEFT JOIN '.hikashop::table('product').' AS a ON b.reference_id=a.product_id WHERE '.implode(' AND ',$filters2).' ORDER BY '.$order;
when joomfish is installed.
Please Log in or Create an account to join the conversation.
- jameswadsworth
-
Topic Author
- Offline
Home
Category1 > Subcategory1 > AnotherSubcategory1
Category2 > Subcategory2 > AnotherSubcategory2
Category3 > Subcategory3 > AnotherSubcategory3
Category4 > Subcategory4 > AnotherSubcategory4
So you can we don't have single itemid that satisfies the setting for each view. The solution in these posts worked well. I presume when the the manufacture option was added it was removed for some reason. (edit - sorry, getting confused. This was implemented for the product search - now I am going see if something similar can be implemented to get the itemid if the itemid is not set in the category plugin.)
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
- jameswadsworth
-
Topic Author
- Offline
Please Log in or Create an account to join the conversation.
does it comes to a solution to find the correct menu-itemid for each product listed ?
Is there a function that could be used to retrieve it in Content Display module to set the itemid in the $link variable ?
I suppose it should be updated in the code of listing_img_title.php as an override ...
... an option in module that say "auto get product item-id if exists !" would also be a great way !
Please Log in or Create an account to join the conversation.
It is what we done using the "product canonical url" and the new option in HikaShop 1.4.1
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
I've set "Force canonical URLs on listings = Use canonical URL and generate it if missing"
but the Itemid is always still the same for each product in list.
Looking at the code of listing_img_title.php doesn't seems to try to get the menu item anywhere,
it couldn't be easy to find, not just with a simple query, because I suppose we have to search in all menu items for a param like {product_id: ... }
Please Log in or Create an account to join the conversation.
I've updated two files in components/com_hikashop/views/product/tmpl/
(I think that once these becomes working these could be put as overrides in template joomla dir)
Add this code to listing_div.php
and updated the $link variable in listing_img_title.php like:
What do you think about it ?
I know it's not really a good coding and not so good for performance, because it retrieves many menu items without filtering over the category on the query.
Thank you for any suggestion !
Please Log in or Create an account to join the conversation.
can i have more information about
- the itemid : id of the menu ( module) or one of the id of a menu ( one of the list title of the menu )
- the relation beetween itemid and Canonical URL ?
thank's
Please Log in or Create an account to join the conversation.
- An Itemid is an Itemid... It's a Joomla menu.
- There is no relation between them.
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Please Log in or Create an account to join the conversation.
then it is the id of each menu item useful when you need to enable a module for a certain page by the settings of the module itself.
If this element isn't present in the url the module will not be loaded.
Please Log in or Create an account to join the conversation.