| Current Path : /home/azimutno/www/demo/plugins/nextendslidergenerator/redshop/products/ |
| Current File : /home/azimutno/www/demo/plugins/nextendslidergenerator/redshop/products/generator.php |
<?php
/*
# author Roland Soos
# copyright Copyright (C) Nextendweb.com. All Rights Reserved.
# @license - http://www.gnu.org/licenses/gpl-3.0.txt GNU/GPL
*/
defined('_JEXEC') or die('Restricted access'); ?><?php
nextendimport('nextend.smartslider.generator_abstract');
class NextendGeneratorredshop_products extends NextendGeneratorAbstract {
var $extraFields;
function NextendGeneratorredshop_products($data) {
parent::__construct($data);
$this->extraFields = array();
$this->_variables = array(
'product_id' => 'ID of the product',
'name' => 'Name of the product',
'price' => 'Price of the product',
'url' => 'Url of the product',
'short_description' => 'Short description of the product',
'description' => 'Description of the product',
'category_id' => 'Id of the product\'s category',
'category_name' => 'Name of the product\'s category',
'category_short_description' => 'Short description of the product\'s category',
'category_description' => 'Description of the product\'s category',
'category_url' => 'Url to the product\'s category',
'man_name' => 'Name of the product\'s manufacturer',
'image' => 'Image for the product',
'thumbnail' => 'Thumbnail for the product'
);
}
function getData($number) {
nextendimport('nextend.database.database');
$db = NextendDatabase::getInstance();
require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/redshop.cfg.php';
require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/configuration.php';
require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/template.php';
require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/stockroom.php';
require_once JPATH_ADMINISTRATOR . '/components/com_redshop/helpers/economic.php';
require_once JPATH_SITE . '/components/com_redshop/helpers/product.php';
$Redconfiguration = new Redconfiguration;
$data = array();
$where = array();
$category = array_map('intval', explode('||', $this->_data->get('redshopproductssourcecategory', '')));
if (!in_array(0, $category) && count($category) > 0) {
$where[] = 'pr_cat.category_id IN (' . implode(',', $category) . ') ';
}
if ($this->_data->get('redshopproductssourcepublished', 1)) {
$where[] = ' pr.published = 1 ';
}
if ($this->_data->get('redshopproductssourcespecial', 0)) {
$where[] = ' (pr.product_special = 1) ';
}
if ($this->_data->get('redshopproductssourceonsale', 0)) {
$where[] = ' (pr.product_on_sale = 1) ';
}
$o = '';
$order = NextendParse::parse($this->_data->get('redshopproductsorder1', 'pr.product_name|*|asc'));
if ($order[0]) {
$o .= 'ORDER BY ' . $order[0] . ' ' . $order[1] . ' ';
$order = NextendParse::parse($this->_data->get('redshopproductsorder2', 'pr.product_name|*|asc'));
if ($order[0]) {
$o .= ', ' . $order[0] . ' ' . $order[1] . ' ';
}
}
$query = "SELECT
pr.product_id,
pr.published,
pr_cat.ordering,
pr.product_name as name,
pr.product_s_desc as short_description,
pr.product_desc as description,
man.manufacturer_name as man_name,
pr.product_full_image as image,
pr.product_thumb_image as thumbnail,
pr.product_price,
cat.category_id,
cat.category_name,
cat.category_short_description ,
cat.category_description
FROM `#__redshop_product` AS pr
LEFT JOIN `#__redshop_product_category_xref` AS pr_cat USING (product_id)
LEFT JOIN `#__redshop_category` AS cat USING (category_id)
LEFT JOIN `#__redshop_manufacturer` AS man USING(manufacturer_id)
WHERE pr.product_parent_id=0 ".(count($where) ? ' AND '.implode(' AND ', $where) : '')." ".$o." LIMIT 0, " . $number;
$db->setQuery($query);
$result = $db->loadAssocList();
for ($i = 0; $i < count($result); $i++) {
$product = new producthelper;
$result[$i]['price'] = $product->getProductFormattedPrice($product->getProductPrice($result[$i]['product_id']));
$result[$i]['url'] = 'index.php?option=com_redshop&view=product&pid=' . $result[$i]['product_id'] . '&cid=' . $result[$i]['category_id'];
$result[$i]['category_url'] = 'index.php?option=com_redshop&view=category&cid='.$result[$i]['category_id'].'&layout=detail';
$result[$i]['thumbnail'] = REDSHOP_FRONT_IMAGES_ABSPATH . "product/".$result[$i]['thumbnail'];
$result[$i]['image'] = REDSHOP_FRONT_IMAGES_ABSPATH . "product/".$result[$i]['image'];
}
return $result;
}
}