繁体   English   中英

opencart需要在管理面板中显示每个产品的选项数量

[英]opencart Need to show option quantity in admin panel per product in

我真的很需要这个,因为我的大多数产品在Opencart中都有选项。 我需要在管理员列表中显示每种产品的选项数量。

此刻在数量列中仅显示一个数字。 最好是说草莓:12香草:5。

有人可以帮帮我吗?

您应该做的第一件事是在OpenCart扩展页面上查看是否有扩展名。 如果没有扩展名,那么您将需要执行此操作。 1)查找此信息位于哪个数据库表中(我认为是其产品)。 然后在模型中查询它,将其传递给控制器​​,然后在视图中回显该变量/数组。 我将大致为您提供所需的代码,但是您需要对其进行调整以执行所需的操作。 这应该放在适当的模型文件中:

public function getProductName() {
     $query = $this->database->query("SELECT * product_name FROM product"); /*this gets all the info you want, however I am not %100 on the names, so double check your database*/
if (isset($query){ /*says if array is not NULL and is set*/
return getProductName(); /* return the function */ 
}
else {$query = ""} /*else the array is NULL*/
{

这应该在您的控制器中:

$this->load->model('path/to/model/file') /*however you might not need this depending on which model file you place your query (model code)*/
$this->data['productName'] = $this->path_to_model->getProductName(); /*this passes it to your view file as the array productName*/

这应该在您的视图中:

您将在视图页面上看到某些HTML标记和foreach循环,您将希望基本上复制视图代码以正确显示数组,但是它看起来应该像这样:

 <tr>
 <td>
      <?php foreach ($productName->rows as $tempVariable) { /*this is roughly how you will get each product name from database table to print on a page, obviously if you want to display it next to its quantity you will need to change it around by using HTML and PHP code in conjugation, however I hope this has helped*/
            echo $tempVariable; ?>
 </td>
 </tr>

暂无
暂无

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

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