- Posts: 48
- Thank you received: 1
Get product name in view without variant append.
11 years 7 months ago #190524
by Llarian
Get product name in view without variant append. was created 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?
-- 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.
11 years 7 months ago #190546
by nicolas
Replied by nicolas on topic Get product name in view without variant append.
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.
11 years 7 months ago #190589
by Llarian
Replied by Llarian on topic Get product name in view without variant append.
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?
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.
11 years 7 months ago #190601
by Xavier
Replied by Xavier on topic Get product name in view without variant append.
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.
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