Answer the question
In order to leave comments, you need to log in
How to adapt OpenCart 1.X code to OpenCart 2.3?
The code for the "Show more" button is laid out for version 1.x, you need to adjust it for 2.3
In the file catalog/controller/product/category.php, after $product_total = $this->model_catalog_product->getTotalProducts($filter_data); add:
I changed this to $data['ttl']
In catalog/view/theme/default/template/product/category.tpl, before echo $pagination; add:$this->data['ttl'] = $product_total;
<?php if($ttl > count($products)){ ?>
<input type="hidden" value="<?php echo $this->config->get('config_catalog_limit') + count($products); ?>" name="limit" id="pagin_limit">
<?php if(($ttl - count($products)) >= $this->config->get('config_catalog_limit')){ ?>
<div class="category_load">Показать еще <?php echo $this->config->get('config_catalog_limit'); ?></div>
<?php }else{ ?>
<div class="category_load">Показать еще <?php echo $ttl-count($products); ?></div>
<?php } ?>
<script>
$(".category_load").on("click", function(){
product_div = '.products';
lim = $("#pagin_limit").val();
$("." + product_div).load('index.php?route=product/category&path=<?php echo $this->request->get['path']; ?>&limit=' + lim + ' ' + product_div + '>*', function(){
$("#pagin_limit").val(lim);
});
});
</script>
<?php } ?>
Answer the question
In order to leave comments, you need to log in
I haven’t picked up opencart for a long time ((
1) You need to debug (it’s good if x-debug is installed and configured), if not, then the good old var_dump(); die;
2) find out what $product_total comes in (see point 1) there should be the number of products
3) by clicking on the button, an ajax request should be called in the console, you need to make sure that it happens and there are no js errors. Next, you need to check the status of the response, whether there is a corresponding action to which the request is sent.
just as embarrassing
product_div = '.products';
....
$("." + product_div)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question