News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

product-neighbours for all products in different categories

Started by Mayapi, December 02, 2016, 12:51:58 PM

Previous topic - Next topic

Mayapi

Hello, i have start a work on the product-neighbours Buttons and i see this code is not able to take all the products ID if the products are placed in multiple categories.

The problem is : You cant have only one category for hundred of products all differents, so you have to create lot of categories for being well organised.

My question is : Is it possible to enhanced the actual code for making this buttons searching in all categories and display all the products of the shop .

I begin an ultra flat style shop and my button are placed in absolute postioning, each buttons are on the side of the screen like fullscreen slider buttons and i need to enhance this product-neighbours for display simply all products of the shop with a simple clic on left or right button.

Anyone know what i have to change in that code , im not very familiar with sql queries :

<div class="product-neighbours">

                <?php

                if (!empty($this->product->neighbours ['previous'][0])) {

                $prev_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['previous'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE);

                echo JHtml::_('link', $prev_link, $this->product->neighbours ['previous'][0] ['product_name'], array('rel'=>'prev', 'class' => 'previous-page pull-left','data-dynamic-update' => '1'));

                }

                if (!empty($this->product->neighbours ['next'][0])) {

                $next_link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' . $this->product->neighbours ['next'][0] ['virtuemart_product_id'] . '&virtuemart_category_id=' . $this->product->virtuemart_category_id, FALSE);

                echo JHtml::_('link', $next_link, $this->product->neighbours ['next'][0] ['product_name'], array('rel'=>'next','class' => 'next-page pull-right','data-dynamic-update' => '1'));

                }

                ?>

                </div>


Studio 42

It's complex to change this and need a big querie and many validity check, because this depend your shop settings, ordering.
First you need to get the current product from DB.
Then get next and before, get the products using the model to check stock ...
So if you need it then check the product model neighbours  function ,copy it and modify it for your needs. In a simple query you cannot get this correctly.