Joomla Virtuemart 2.x

时间:2013-03-13 21:27:46

标签: joomla virtuemart

即时交易显示在产品详细信息页面中,由同一制造商列出的其他产品。我的意思是,如果你穿着阿迪达斯的鞋子,该页面会显示另一个adidas产品。所以我有这个代码:

http://codepad.org/pO8XF0OI(不知道如何在这里编写代码)

实际上是在工作,但仅按制造商的类别no显示产品。

我做错了什么?

2 个答案:

答案 0 :(得分:0)

试试这个,

如果您使用的是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);

希望这可能有所帮助...

答案 1 :(得分:0)

完成后,这是代码:

<?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 } ?>