Skip to main content

Get product name in view without variant append.

More
11 years 7 months ago #190524 by Llarian
-- url of the page with the problem -- : www.weareecs.com/shop/categories/product/3-ecs-membership-2015
-- HikaShop version -- : 2.3.5
-- Joomla version -- : 2.5.28
-- PHP version -- : 5.4.37

I have a bit of custom code in the product->show view to set the page title to:

<Shop Name> - <Category> - <Product Name>

This is mostly working, but the product name is being appended with the variant information inside a <span> tag. I really just want the parent product name to display.

My code looks like this currently:

$doc =& JFactory::getDocument();
$class = hikashop::get('class.category');
$cat = $class->get($this->element->category_id);
$doc->setTitle('ECS Shop - ' . $cat->category_name . ' - ' . $this->element->product_name);


For products without variants, this works great. But a product with a variant is showing up as (for example):

ECS Shop - Membership - ECS Membership 2015<span class="hikashop_product_variant_subname">: Full Membership ECS - No subgroup</span>:

I'd like this to be:

ECS Shop - Membership - ECS Membership 2015


Is there any way to grab the product name sans variant info anywhere?

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #190546 by nicolas
You want to do like that then:
Code:
$doc =& JFactory::getDocument(); $class = hikashop::get('class.category'); $cat = $class->get($this->element->category_id); if(!empty($this->element->main)) $doc->setTitle('ECS Shop - ' . $cat->category_name . ' - ' . $this->element->main->product_name); else $doc->setTitle('ECS Shop - ' . $cat->category_name . ' - ' . $this->element->product_name);

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #190589 by Llarian
Perfect, thank you!

Out of curiosity, is the ORM documented somewhere? For example, the element->main accessor would have made this an easy problem to solve. Are these classes/methods available in any documentation?

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #190601 by Xavier
Hi,

We have some documentation about that but not all the details.
Here is a link for a product PHP object:
www.hikashop.com/support/documentation/157

From the developer documentation:
www.hikashop.com/support/support/documen...ntation.html#objects

To see a full object in php you can still use the var_dump() function.

Please Log in or Create an account to join the conversation.

Time to create page: 0.182 seconds
Powered by Kunena Forum