Добрый день, уважаемые форумчане. Нужна ваша помощь.
Есть модуль, который выводит товары. В настройках есть возможность задать id категории из которой будут браться товары, но мне нужно задать id конкретных товаров, которые будут выводится... Подскажите, пожалуйста, как правильно прописать запрос, чтобы товары выводились по id
<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
* @Copyright Copyright (C) 2010 VTEM . All rights reserved.
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
* @link http://www.vtem.net
**/
global $mosConfig_absolute_path;
// Load the VirtueMart main parse code
if( file_exists(dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' )) {
require_once( dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' );
} else {
require_once( dirname(__FILE__).'/../components/com_virtuemart/virtuemart_parser.php' );
}
$max_items = $params->get( 'max_items', 8 ); //maximum number of items to display
$category_id = $params->get( 'category_id', null ); // Display products from this category only
$display_style = $params->get( 'display_style', "horizontal" ); // Display Style
$nav_style = $params->get( 'nav_style', "style1" ); // Display Style
$show_price = (bool)$params->get( 'show_price', 1 ); // Display the Product Price?
$show_addtocart = (bool)$params->get( 'show_addtocart', 1 ); // Display the "Add-to-Cart" Link?
$image_size = $params->get( 'image_size', 1 );
$image_width = $params->get( 'image_width', 150 );
$image_height = $params->get( 'image_height', 100 );
$background = $params->get( 'background', 1 );
$loadscript = $params->get( 'loadscript', 1 );
$scroller_id = $params->get( 'moduleID', 'VtemScroller1' );
$module_width = $params->get('module_width', 500);
$module_height = $params->get('module_height', 250);
$slide_size = $params->get('slide_size', 200);
$slide_interval = $params->get('slide_interval', 3000);
$scrollbar = 1; /* 0: hide, 1: show, currently only show supported*/
$autoplay = $params->get('autoplay', 1)? 'true' : 'false';
$feature = $params->get('feature', 1)? "AND #__{vm}_product.product_special='Y' \n" : " ";
$scrollarea_size = ($scrollbar)? 20 : 0;
$scrollarea_width = $module_width - 20;
$scrollarea_height = $scrollarea_size;
$scrollbar_width = $scrollarea_width - 72;
$scrollbar_height = $scrollarea_height;
$panel_width = $module_width - 10;
$panel_height = $module_height - $scrollarea_size - 8;
$slide_width = $slide_size < $panel_width ? $slide_size : $panel_width;
$knob_offset = 0;
if ($display_style == "vertical"){
$scrollarea_size = ($scrollbar)? 25 : 0;
$scrollarea_width = $scrollarea_size - 1;
$scrollarea_height = $module_height - 20;
$scrollbar_width = $scrollarea_width;
$scrollbar_height = $scrollarea_height-75;
$panel_width = $module_width - $scrollarea_size;
$panel_height = $module_height - 10;
$slide_width = $panel_width;
}
$css_scrollarea_width = 'width: ' . $scrollarea_width . 'px;';
$css_scrollarea_height = 'height: ' . $scrollarea_height . 'px;';
$css_scrollbar_width = 'width: ' . $scrollbar_width . 'px;';
$css_scrollbar_height = 'height: ' . $scrollbar_height . 'px;';
$css_slide_width = 'width: ' . $slide_width . 'px;';
if ($display_style == "vertical") $css_slide_height = 'height: ' . $slide_size . 'px;'; /* only needed for vertical layout */
$css_module_width = 'width: ' . $module_width . 'px;';
$css_module_height = 'height: ' . $module_height . 'px;';
$css_panel_width = 'width: ' . $panel_width . 'px;';
$css_panel_height = 'height: ' . $panel_height . 'px;';
$css_total_panel_width = 'width: ' . ($slide_width * $max_items). 'px;'; /* only needed for horizontal layout */
switch ($params->get( 'order' ))
{
case 'rnd':
$ordering = 'ORDER BY RAND()';
break;
case 'name':
$ordering = 'ORDER BY #__{vm}_product.product_name ASC';
break;
case 'c_dsc':
default:
$ordering = 'ORDER BY #__{vm}_product.product_id DESC';
break;
}
require_once ( CLASSPATH. 'ps_product.php');
$ps_product = new ps_product;
$db = new ps_DB;
if ( $category_id ) {
// BEGIN - MultiCategory Display - deneb
$cat_ids = explode(",",$category_id);
if (count($cat_ids) > 1){
$multi_cats = 1;
}
// END - MultiCategory Display - deneb
$q = "SELECT DISTINCT product_sku FROM #__{vm}_product, #__{vm}_product_category_xref, #__{vm}_category WHERE \n";
$q .= "(#__{vm}_product.product_parent_id='' OR #__{vm}_product.product_parent_id='0') \n";
$q .= "AND #__{vm}_product.product_id=#__{vm}_product_category_xref.product_id \n";
$q .= "AND #__{vm}_category.category_id=#__{vm}_product_category_xref.category_id \n";
// BEGIN - MultiCategory Display - deneb
if ($multi_cats){
$i = 1;
$q .= "AND (";
foreach ($cat_ids as $cat_id){
if ($i == count($cat_ids)){
$q .= "(#__{vm}_category.category_id='$cat_id')";
} else {
$q .= "(#__{vm}_category.category_id='$cat_id') OR \n";
}
$i++;
}
$q .= ") \n";
} else {
$q .= "AND #__{vm}_category.category_id='$category_id' \n";
}
// END - MultiCategory Display - deneb
$q .= "AND #__{vm}_product.product_publish='Y' \n" .$feature;
//$q .= "AND #__{vm}_product.product_special='Y' \n";
if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
$q .= " AND product_in_stock > 0 \n";
}
$q .= $ordering. " LIMIT 0, $max_items";
}
else {
$q = "SELECT DISTINCT product_sku FROM #__{vm}_product WHERE ";
$q .= "(#__{vm}_product.product_parent_id='' OR #__{vm}_product.product_parent_id='0') AND vendor_id='".$_SESSION['ps_vendor_id']."' ";
$q .= "AND #__{vm}_product.product_publish='Y' " .$feature;
//$q .= "AND #__{vm}_product.product_special='Y' ";
if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
$q .= " AND product_in_stock > 0 ";
}
$q .= $ordering. " LIMIT 0, $max_items";
}
$db->query($q);
?>
<style type="text/css">
<?php if($image_size == 1){
echo ".vtem-scroller div.panel div.slide img{width:".$image_width."px !important;height:".$image_height."px !important;margin:0;}";
}
if($background == 1){
?>
.vtem-scroller{
background:#fff url(modules/mod_vtem_virtuemart_scroller/common/images/module_bg.gif) left bottom repeat-x;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
border:1px solid #e5e5e5;
behavior:url(modules/mod_vtem_virtuemart_scroller/common/rounded.htc);
position:relative;
z-index:10;
}
<?php }?>
.vtem_horizontal_<?php echo $nav_style;?>{
background:url(modules/mod_vtem_virtuemart_scroller/common/images/arrow_left_<?php echo $nav_style;?>.gif) no-repeat;
}
.vtem_horizontal_<?php echo $nav_style;?> .vtem_scrollarrow{
background:url(modules/mod_vtem_virtuemart_scroller/common/images/arrow_right_<?php echo $nav_style;?>.gif) right top no-repeat;
height:20px;
}
.vtem_horizontal_<?php echo $nav_style;?> .vtemscrollbar{
background:url(modules/mod_vtem_virtuemart_scroller/common/images/arrow_mid_<?php echo $nav_style;?>.gif) right top repeat-x;
}
.vtem_vertical_<?php echo $nav_style;?>{
background:url(modules/mod_vtem_virtuemart_scroller/common/images/varrow_left_<?php echo $nav_style;?>.gif) no-repeat;
float:right;
margin:10px 0;
padding:0;
}
.vtem_vertical_<?php echo $nav_style;?> .vtem_scrollarrow{
background:url(modules/mod_vtem_virtuemart_scroller/common/images/varrow_right_<?php echo $nav_style;?>.gif) left bottom no-repeat;
padding:0;
<?php echo $css_scrollarea_height;?>
}
.vtem_vertical_<?php echo $nav_style;?> .vtemscrollbar{
background:url(modules/mod_vtem_virtuemart_scroller/common/images/varrow_mid_<?php echo $nav_style;?>.gif) left top repeat-y;
margin:10px 18px 0 0 !important;
_margin:10px 0 0 0 !important;
padding:0 !important;
}
</style>
<div id="<?php echo $scroller_id ?>" class="vtem-scroller <?php echo $display_style;?>" style=" <?php echo $css_module_width . $css_module_height;?>">
<div class="panel" style=" <?php echo $css_panel_width . $css_panel_height;?>">
<?php
$i = 0;
while($db->next_record() ){
if( $display_style == "vertical" ) {
echo "<div class=\"slide\" style='".$css_slide_width . $css_slide_height."' align=\"center\">";
$ps_product->show_snapshot($db->f("product_sku"), $show_price, $show_addtocart);
echo "</div>\n";
}
elseif( $display_style== "horizontal" ) {
if( $i == 0 )
echo "<div style='".$css_total_panel_width."'>";
echo "<div class=\"slide\" style='".$css_slide_width."' align=\"center\">";
$ps_product->show_snapshot($db->f("product_sku"), $show_price, $show_addtocart);
echo "</div>\n";
if( ($i+1) == $db->num_rows() )
echo "</div>\n";
}
$i++;
}
?>
</div>
<?php if ($scrollbar) : ?>
<div class="vtem_scrollarea vtem_<?php echo $display_style.'_'.$nav_style;?>" style=" <?php echo $css_scrollarea_width . $css_scrollarea_height;?>">
<div class="vtem_scrollarrow">
<div class="back"></div>
<div class="vtemscrollbar" style="<?php echo $css_scrollbar_width . $css_scrollbar_height ?>">
<div class="scrollknob scrollknob-size">
<div class="scrollknob_right">
<div class="scrollknob_mid">
</div>
</div>
</div>
</div>
<div class="forward"></div>
</div>
</div>
<?php endif; ?>
<div style="clear:both"></div>
</div>
<?php
if($loadscript == 1){
echo '<script src="media/system/js/mootools.js" type="text/javascript"></script>';
}
$document =& JFactory::getDocument();
$javascript = "new VTEMscroller('" . $scroller_id . "', { mode: '" . $display_style . "', slideInterval: " . $slide_interval . ", autoplay: " . $autoplay . ", knobOffset: " . $knob_offset . " });";
$document->addStyleSheet('modules/mod_vtem_virtuemart_scroller/common/style.css');
if($loadscript == 1){
$document->addScript('media/system/js/mootools.js');
}
$document->addScript('modules/mod_vtem_virtuemart_scroller/common/vtem_scroller.js');
echo "<script type=\"text/javascript\">\n// <!--\n$javascript\n// -->\n</script>\n";
?>