News:

Looking for documentation? Take a look on our wiki

Main Menu

2 improvment for customfields model

Started by Studio 42, July 06, 2015, 23:39:19 PM

Previous topic - Next topic

Studio 42

Hi all,
When you get associate categories, no cache(static vars) are used.
i changed the code in customfields model to use a static var for function displayProductCustomfieldFE in case 'Z':

case 'Z':
if(empty($customfield->customfield_value)) break;
$cid = (int)$customfield->customfield_value ;
static $fieldZ = array();
$html = '';
if(!isset($fieldZ[$cid ])) {
$q  = 'SELECT l.`category_name`,c.`virtuemart_category_id`,`virtuemart_media_id` FROM `#__virtuemart_categories_' . VmConfig::$vmlang . '` as l INNER JOIN `#__virtuemart_categories` AS c using (`virtuemart_category_id`)';
$q .= ' LEFT JOIN `#__virtuemart_category_medias` as cm on cm.`virtuemart_category_id`=c.`virtuemart_category_id`';
$q .= ' WHERE `published`=1 AND l.`virtuemart_category_id`= "' . (int)$cid  . '" ';
$db = JFactory::getDBO();
$db->setQuery ($q);
$fieldZ[$cid ] = $db->loadObject ();
}
if ($category = $fieldZ[$cid ]) {
$thumb = '';
if ($category->virtuemart_media_id) {
$thumb = $this->displayCustomMedia ($category->virtuemart_media_id,'category',$customfield->width,$customfield->height);
}
$customfield->display = JHtml::link (JRoute::_ ('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $category->virtuemart_category_id), $thumb . ' ' . $category->category_name, array('title' => $category->category_name,'target'=>'_blank'));
}
break;


This remove all duplicate queries for associate categories in Joomla report.

always in function displayProductCustomfieldFE
for case 'R':
if(!$related) break;

to
if(!$related) {
unset($customfields[$k]);
break;
}


prevent to display empty related product result, already reported, but fix is not in latest downloadable vm release.

Greets,
Patrick