VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: nastjushka on July 17, 2015, 11:22:10 AM

Title: Conclusion in a goods card the name of parental category
Post by: nastjushka on July 17, 2015, 11:22:10 AM
I have a difficult catalog of type:

Detail type
- Car brand
-- Car model

I can't change structure - it is unloaded from 1C, the Catalogue very big and goods is a lot of, manually I can't appropriate to each goods also parental categories...

I need to specify "Detail type", that is parental category of goods in a card of goods how to make it?

Help me, please.
Title: Re: Conclusion in a goods card the name of parental category
Post by: nastjushka on July 20, 2015, 12:04:09 PM
solution here  http://joomlaforum.ru/index.php/topic,315914.msg1572350.html#msg1572350 (http://joomlaforum.ru/index.php/topic,315914.msg1572350.html#msg1572350)

<?php
$cat 
VmModel::getModel('category');
$parent $cat->getParentCategory((int)$this->product->virtuemart_category_id);
if( 
$parent->virtuemart_category_id ){
$grandparent $cat->getParentCategory((int)$parent->virtuemart_category_id);
if( $grandparent->category_name ){
echo $grandparent->category_name;
}else{
echo $parent->category_name;}
} else {
echo 
$product->category_name;}
?>