我正在处理以在产品详细信息页面中显示同一制造商的其他产品列表。我的意思是,如果你穿着阿迪达斯的鞋子,页面会显示另一个阿迪达斯产品。所以我有这个代码:
http://codepad.org/pO8XF0OI(这里不知道怎么写代码)
实际工作,但仅按制造商的类别显示产品。
我做错了什么?
我正在处理以在产品详细信息页面中显示同一制造商的其他产品列表。我的意思是,如果你穿着阿迪达斯的鞋子,页面会显示另一个阿迪达斯产品。所以我有这个代码:
http://codepad.org/pO8XF0OI(这里不知道怎么写代码)
实际工作,但仅按制造商的类别显示产品。
我做错了什么?
试试这个,
如果您使用的是 Vm2.x,它将为您提供一个制造商下的完整产品。您可以根据您的要求添加或删除另一个表。
$db = &JFactory::getDBO();
$sql = "SELECT N.product_name,M.virtuemart_product_id,MN.mf_name
FROM jos_virtuemart_product_manufacturers AS M
LEFT JOIN jos_virtuemart_products AS P ON M.virtuemart_product_id = P.virtuemart_product_id
LEFT JOIN jos_virtuemart_products_en_gb AS N ON N.virtuemart_product_id = M.virtuemart_product_id
LEFT JOIN jos_virtuemart_manufacturers_en_gb AS MN ON MN.virtuemart_manufacturer_id = M.virtuemart_manufacturer_id
WHERE M.virtuemart_manufacturer_id = '$manufature_id'";
$db->setQuery($sql);
$db->query();
$res = $db->loadAssocList();
echo "<pre/>";
print_r($res);
希望这可能会有所帮助...
大功告成,代码如下:
<?php
$db = &JFactory::getDBO();
$manufacturer = $this->product->virtuemart_manufacturer_id;
$sql = "SELECT N.product_name,I.virtuemart_media_id,M.virtuemart_product_id,MN.mf_name
FROM h3ls8_virtuemart_product_manufacturers AS M
LEFT JOIN h3ls8_virtuemart_products AS P ON M.virtuemart_product_id = P.virtuemart_product_id
LEFT JOIN h3ls8_virtuemart_products_es_es AS N ON N.virtuemart_product_id = M.virtuemart_product_id
LEFT JOIN h3ls8_virtuemart_product_medias AS I ON M.virtuemart_product_id = I.virtuemart_product_id
LEFT JOIN h3ls8_virtuemart_manufacturers_es_es AS MN ON MN.virtuemart_manufacturer_id = M.virtuemart_manufacturer_id
WHERE M.virtuemart_manufacturer_id = '$manufacturer'"; // h3ls8_ is your table Prefix
$db->setQuery($sql);
$db->query();
/* $res = $db->loadAssocList(); //This Load the info as a List */
$prod = $db->loadObjectList(); // This Load the info as a group of objects for loading it.
JRequest::setVar('virtuemart_manufacturer_id',$this->product->virtuemart_manufacturer_id,'GET');
$productModel = VmModel::getModel('product');
if ($this->product->virtuemart_manufacturer_id !=0 ) {
$products = $prod;
$productModel->addImages($products);
$this->assignRef('products', $products);
}
// Show Products
if (!empty($products)) { ?>
<div class="seven columns obras">
<h5> Obras </h5>
<div class="row">
<?php
// Start the Output
foreach ($products as $product) {
// Show Products
?>
<div class="four columns mobile-two end producto">
<div class="imagen">
<!-- <?php //if ($product->product_special == 1) { ?>
<div class="oferta">
<br />
</div>
<?php}?> *** If you wanna add some especial icon to a Special product uncommnent this *** -->
<?php
echo JHTML::_('link', JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product->virtuemart_product_id.'&virtuemart_category_id='.$product->virtuemart_category_id),$product->images[0]->displayMediaThumb('class="catImage"',false));
?>
</div>
</div> <!-- end of product -->
<?php } ?>
</div>
</div>
<?php } ?>