[Skip to main content](#vessel-content)

#   how to get Category NAME in the Product

##

- **[Eight4Eight](/forum/user/28765-eight4eight "View Eight4Eight's Profile")**
- [![Eight4Eight's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/28765-eight4eight "View Eight4Eight's Profile") Topic Author
- [ Offline](/forum/user/28765-eight4eight)

Less More

- Posts: 11
- Thank you received: 0
-
-

12 years 10 months ago [\#136092](#136092) by [Eight4Eight](/forum/user/28765-eight4eight "View Eight4Eight's Profile")  *[how to get Category NAME in the Product](/forum/25-install-update/864266-how-to-get-category-name-in-the-product#136092 "-- url of the page with the problem -- :   eight4eight.com/joomla/index.php/categor...-with-the-hippy-boys  -- HikaShop version -- : HikaShop Essential 2.2.2, Joomla!™ Online Store Component -- Joomla version -- : 3.2 -- PHP version -- : 5.4 -- Browser(s) name and version -- : chrome - latest -- Error-message(debug-mod must be tuned on) -- : Error&#95;message  I would like to show the category before the Product Name in each product independently- regardless of if the user gets to the page by brand or category.. how can I accomplish this task? I can open the product template - but I do not know how to call out and echo the product name? Thanks in advance.  I appreciate any help in this direction..")* was created by *[Eight4Eight](/forum/user/28765-eight4eight "View Eight4Eight's Profile")*

-- url of the page with the problem -- : [ eight4eight.com/joomla/index.php/categor...-with-the-hippy-boys](http://eight4eight.com/joomla/index.php/categories/product/18659-reggae-with-the-hippy-boys)
-- HikaShop version -- : HikaShop Essential 2.2.2, Joomla!™ Online Store Component
-- Joomla version -- : 3.2
-- PHP version -- : 5.4
-- Browser(s) name and version -- : chrome - latest
-- Error-message(debug-mod must be tuned on) -- : Error_message

I would like to show the category before the Product Name in each product independently- regardless of if the user gets to the page by brand or category.. how can I accomplish this task? I can open the product template - but I do not know how to call out and echo the product name? Thanks in advance.

I appreciate any help in this direction..

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzg2NDI2Ni1ob3ctdG8tZ2V0LWNhdGVnb3J5LW5hbWUtaW4tdGhlLXByb2R1Y3Q/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26394
- Thank you received: 4078
-
- [](http://obsi.dev)
-

12 years 10 months ago [\#136111](#136111) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[how to get Category NAME in the Product](/forum/25-install-update/864266-how-to-get-category-name-in-the-product#136111 "-- url of the page with the problem -- :   eight4eight.com/joomla/index.php/categor...-with-the-hippy-boys  -- HikaShop version -- : HikaShop Essential 2.2.2, Joomla!™ Online Store Component -- Joomla version -- : 3.2 -- PHP version -- : 5.4 -- Browser(s) name and version -- : chrome - latest -- Error-message(debug-mod must be tuned on) -- : Error&#95;message  I would like to show the category before the Product Name in each product independently- regardless of if the user gets to the page by brand or category.. how can I accomplish this task? I can open the product template - but I do not know how to call out and echo the product name? Thanks in advance.  I appreciate any help in this direction..")*

Hi,

Basically, it is not really possible like that to display the category name in the product page.
The reason is simple : a product can have multiple categories. You can't know in which one you are except if you use a category list (like the breadcrumb do).

But in the product page view, you can access to " $this-&gt;categories " which is an array of the product categories.
It contains the categories object, so you can do Code:

$first_category = reset($this-&gt;categories); echo $first_category-&gt;category_name;

If you want to display the category name of the first category of the product.

But be careful, like I said in the beginning of the message, you can have wrong display if your product have several categories and the navigation can display the product from another category than the first product category.

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzg2NDI2Ni1ob3ctdG8tZ2V0LWNhdGVnb3J5LW5hbWUtaW4tdGhlLXByb2R1Y3Q/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Nello](/forum/user/1361-nello "View Nello's Profile")**
- [![Nello's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/1361-nello "View Nello's Profile")
- [ Offline](/forum/user/1361-nello)

Less More

- Posts: 251
- Thank you received: 2
-
-

11 years 2 months ago -  11 years 2 months ago [\#210958](#210958) by [Nello](/forum/user/1361-nello "View Nello's Profile")  Replied by *[Nello](/forum/user/1361-nello "View Nello's Profile")* on topic *[how to get Category NAME in the Product](/forum/25-install-update/864266-how-to-get-category-name-in-the-product#210958 "-- url of the page with the problem -- :   eight4eight.com/joomla/index.php/categor...-with-the-hippy-boys  -- HikaShop version -- : HikaShop Essential 2.2.2, Joomla!™ Online Store Component -- Joomla version -- : 3.2 -- PHP version -- : 5.4 -- Browser(s) name and version -- : chrome - latest -- Error-message(debug-mod must be tuned on) -- : Error&#95;message  I would like to show the category before the Product Name in each product independently- regardless of if the user gets to the page by brand or category.. how can I accomplish this task? I can open the product template - but I do not know how to call out and echo the product name? Thanks in advance.  I appreciate any help in this direction..")*

Is it possible to get the last category, instead of the first?

Thank you!

Last edit: 11 years 2 months ago by [Nello](/forum/user/1361-nello "View Nello's Profile").

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzg2NDI2Ni1ob3ctdG8tZ2V0LWNhdGVnb3J5LW5hbWUtaW4tdGhlLXByb2R1Y3Q/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Away](/forum/user/63-nicolas)

Less More

- Posts: 86299
- Thank you received: 14273
-
-

11 years 2 months ago [\#210976](#210976) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[how to get Category NAME in the Product](/forum/25-install-update/864266-how-to-get-category-name-in-the-product#210976 "-- url of the page with the problem -- :   eight4eight.com/joomla/index.php/categor...-with-the-hippy-boys  -- HikaShop version -- : HikaShop Essential 2.2.2, Joomla!™ Online Store Component -- Joomla version -- : 3.2 -- PHP version -- : 5.4 -- Browser(s) name and version -- : chrome - latest -- Error-message(debug-mod must be tuned on) -- : Error&#95;message  I would like to show the category before the Product Name in each product independently- regardless of if the user gets to the page by brand or category.. how can I accomplish this task? I can open the product template - but I do not know how to call out and echo the product name? Thanks in advance.  I appreciate any help in this direction..")*

Hi,

Yes.
Instead of the PHP reset function you can use the end function in order to get the last one.

The following user(s) said Thank You: [Nello](/forum/user/1361-nello "View Nello's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI1LWluc3RhbGwtdXBkYXRlLzg2NDI2Ni1ob3ctdG8tZ2V0LWNhdGVnb3J5LW5hbWUtaW4tdGhlLXByb2R1Y3Q/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop- Install &amp; Update- Product &amp; Category Display- Content Creation- Sales and Orders- - Orders management- - Reports &amp; Statistics- Customers- Checkout- Payment Methods- Shipping Methods- Import &amp; Export (CSV, XLS…)- Specific Features- - Affilation- - Taxes- - Wishlist- - Vote- - Carousel &amp; Slider- - Mass Actions- - Filters &amp; Search- - Discount &amp; Coupon- - Feature Request- Integrations- Showcase- General Talk about HikaShop- Development- - HikaShop 3.0 Beta- Translation- Commercial Jobs HikaShop Components- HikaMarket- - Market: Feature requests- - Market: How to?- - Market: Bug Report- HikaSerial- - General talk about HikaSerial- - Serial: Bug Report- - Serial: How to?- - Support en Français de HikaSerial (French Support)- - HikaSubscription- HikaAuction- - Auction: Feature requests- - Auction: How to?- - Auction: Bug report Hikashop around the world- Support en Français (French Support)- Russian- - FAQ. Курс выживания с Hikashop. Частые вопросы и о- - Расширения Hikashop- - Наши сайты на Hikashop- 日本語版サポート(Japanese Support)- Thai- German Archives- Bug Report- How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.108 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)

[](#top)
