简体   繁体   English

在opencart期刊2主题中隐藏缺货产品

[英]Hide out of stock products in journal 2 theme of opencart

without the code , next page link show 没有代码,下一页链接显示

i.stack.imgur.com/0Oniu.jpg i.stack.imgur.com/0Oniu.jpg

with the code the next page link does not show 与代码下一页链接不会显示

i.stack.imgur.com/ljtmr.jpg i.stack.imgur.com/ljtmr.jpg

Help . 救命 。

Code was written by ainosilva 代码由ainosilva编写

http://forum.opencart.com/viewtopic.php?f=20&t=62631#p381559 http://forum.opencart.com/viewtopic.php?f=20&t=62631#p381559

I fixed the issue by increase the number from 0 to 300 我通过将数字从0增加到300来解决此问题

//$product_total = $this->model_catalog_product->getTotalProducts($data); // $ product_total = $ this-> model_catalog_product-> getTotalProducts($ data); $product_total=0; $ product_total = 0;

but when i open second page i still find some out of stock products with incorrect url . 但是当我打开第二页时,我仍然发现一些URL不正确的缺货产品。

i.stack.imgur.com/tagBy.jpg i.stack.imgur.com/tagBy.jpg

Help! 救命!

I'm not sure if you can do it with the theme but I scheduled a task to run a PHP file which changes the status of a product depending on its quantity. 我不确定是否可以使用该主题,但是我安排了一个任务来运行PHP文件,该文件会根据产品的数量更改其状态。 Here is the full script: 这是完整的脚本:

<?php 
$servername = "localhost";
$username = "db_username";
$password = "db_password";
$dbname = "db_name";
$dbprefix = "oc_";
$conn = mysqli_connect($servername, $username, $password, $dbname);

if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$sql = "UPDATE " . $dbprefix . "product SET status = 1 WHERE quantity > 0";
mysqli_query($conn, $sql);

$sql = "UPDATE " . $dbprefix . "product SET status = 0 WHERE quantity < 1";
mysqli_query($conn, $sql);

mysqli_close($conn);
?>

A simpler approach is to update the controller of opencart to update the statement to: 一种更简单的方法是更新opencart的控制器以将语句更新为:

product.status = 1 && product.quantity >0;

Controller file is in catalog->controller->product.php 控制器文件位于目录- catalog->controller->product.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM