%PDF- %PDF-
| Direktori : /home/lightco1/upgrade.lightco.com.au/modules/mod_homevirtuemart/ |
| Current File : /home/lightco1/upgrade.lightco.com.au/modules/mod_homevirtuemart/helper.php |
<?php
class HomeVirtuemartHelper
{
public static function getDetail($params)
{
// var_dump($params); die;
$imgarr = array();
for($i=1;$i<9;$i++){
$url = HomeVirtuemartHelper::getProductncategory($params["b".$i."productid"],$params["b".$i."categoryid"]);
if($params["b".$i."productid"] != null){ if($url == null){ $imgarr["img".$i] = "images/img_not_available.png"; } else{
$imgarr["img".$i] = $url->file_url; }
//
if($params["b".$i."link"] != null){
$imgarr["url".$i] = JRoute::_($params["b".$i."link"]);
} else {
$imgarr["url".$i.""] = JRoute::_("index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=".$params["b".$i."productid"]);
}
}
else{
if($url == null){ $imgarr["img".$i] = "images/img_not_available.png"; } else{
$imgarr["img".$i] = $url->file_url;}
if($params["b".$i."link"] != null){
$imgarr["url".$i] = JRoute::_($params["b".$i."link"]);
} else {
$imgarr["url".$i] = JRoute::_("index.php?option=com_virtuemart&view=category&virtuemart_category_id=".$params["b".$i."categoryid"]);
}
}
}
return $imgarr;
}
public static function getProductncategory($pid, $cid){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('file_url')));
if($pid != null){
$query->from($db->quoteName('#__virtuemart_product_medias', 'a'));
$query->join('INNER', $db->quoteName('#__virtuemart_medias', 'b') . ' ON (' . $db->quoteName('a.virtuemart_media_id') . ' = ' . $db->quoteName('b.virtuemart_media_id') . ')');
$query->where($db->quoteName('a.virtuemart_product_id') . ' = '. $db->quote($pid));
}
else
{
$query->from($db->quoteName('#__virtuemart_category_medias', 'a'));
$query->join('INNER', $db->quoteName('#__virtuemart_medias', 'b') . ' ON (' . $db->quoteName('a.virtuemart_media_id') . ' = ' . $db->quoteName('b.virtuemart_media_id') . ')');
$query->where($db->quoteName('a.virtuemart_category_id') . ' = '. $db->quote($cid)); $query->where($db->quoteName('a.virtuemart_category_id') . ' != 0');
}
$query->order('b.modified_on DESC');
//echo $query; die;
$db->setQuery($query);
$result = $db->loadObject();
return $result;
}
}