AbanteCart Development > Development Help Needed

Create next preview button

<< < (8/8)

maulik 1intl:

--- Quote from: HADY on August 30, 2019, 05:04:20 AM ---nice introduction background video, congratulations.

--- End quote ---
I was complete product page next preview button update in website replay not video bro    :P :P :P :P

baovietgps:
I also want to apply for my website .

maulik 1intl:

--- Quote from: Sam_78 on August 09, 2019, 12:03:18 PM ---You will need to edit core code to get this. Better option is to make an extension

But try this if it works for you because I think you have some custom code already:

https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/pages/product/product.php#L750

if(isset($category_info) && count($category_info) > 0){
         $nextPrevProducts =  $this->model_catalog_product->getProductNextPrevProducts($product_id, $category_info['category_id']);
         $this->data['nextPrevProducts'] = $nextPrevProducts;
      }

right above foreach ($results as $result) {

-----
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/model/catalog/product.php

Add this before last } line

public function getProductNextPrevProducts($productId, $categoryId){
      $sql = "SELECT * FROM " . $this->db->table("products_to_categories") . " WHERE `category_id` = $categoryId and product_id in ( select product_id from " . $this->db->table("products") . " where STATUS = 1)";
      $query = $this->db->query($sql);
      $product_data =  $query->rows;
      $nextPrevProduct = array();
      if(count($product_data) > 0){
         foreach($product_data as $k => $v){
            if($v['product_id'] == $productId){
               $preProductId = isset($product_data[$k - 1]['product_id']) ? $product_data[$k - 1]['product_id'] : 0;
               $nextProductId = isset($product_data[$k + 1]['product_id']) ? $product_data[$k + 1]['product_id'] : 0;
               $cateSql = "SELECT keyword FROM `url_aliases` WHERE `query` LIKE 'category_id=$categoryId'";
               $cateSqlQuery = $this->db->query($cateSql);
               $cateURL =  count($cateSqlQuery->rows) > 0 ? $cateSqlQuery->row['keyword']: '';
               
               $prevProductSql = "SELECT keyword FROM `url_aliases` WHERE `query` LIKE 'product_id=$preProductId'";
               $prevProductSqlQuery = $this->db->query($prevProductSql);
                 $prevProductURL =  count($prevProductSqlQuery->rows) > 0 ? $prevProductSqlQuery->row['keyword']: '';
               
               $nextProductSql = "SELECT keyword FROM `url_aliases` WHERE `query` LIKE 'product_id=$nextProductId'";
               $nextProductSqlQuery = $this->db->query($nextProductSql);
               $nextProductURL =  count($nextProductSqlQuery->rows) > 0 ? $nextProductSqlQuery->row['keyword']: '';
               
               $nextPrevProduct['prev_product'] = (trim($prevProductURL) != '') ? $cateURL . "/" . $prevProductURL : '';
               $nextPrevProduct['next_product'] = (trim($nextProductURL) != '') ? $cateURL . "/" . $nextProductURL : '';
            }
         }
      }
      return $nextPrevProduct;
   }

And last go to product.tpl and add this code where ever you want buttons and style it the way you want.

https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/view/default/template/pages/product/product.tpl#L268

<?php if(is_array($nextPrevProducts)){ ?>   
<div>
   <div style="float: left">
      <?php if(trim($nextPrevProducts['prev_product']) != '') {?>
         <a href="<?php echo trim($nextPrevProducts['prev_product']); ?>" > Previous Product </a>
      <?php } ?>
   </div>
   <div style="float: right">
      <?php if(trim($nextPrevProducts['next_product']) != '') {?>
         <a href="<?php echo trim($nextPrevProducts['next_product']); ?>" > Next Product </a>
      <?php } ?>
   </div>
</div>
<?php } ?>

You can contact AbanteCart developers (they have paid service abantecart.com/contact-us) or some other developers https://www.fiverr.com/nattoben This developer has made few extension for AbanteCart he might be able to help you https://marketplace.abantecart.com/index.php?rt=product/vendor&v=40 

P.S I am not promoting anyone here just trying to help you as what you want is not an easy thing. It needs some custom development

--- End quote ---

Navigation

[0] Message Index

[*] Previous page

Go to full version
Powered by SMFPacks Social Login Mod