Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php opencart需要在每个产品的管理面板中显示选项数量_Php_Opencart - Fatal编程技术网

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

Php opencart需要在每个产品的管理面板中显示选项数量,php,opencart,Php,Opencart,我真的需要这个,因为我的大多数产品在Opencart中都有选项。我需要在管理员列表中显示每个产品的选项数量 目前在数量栏中,它只显示了一个数字。如果上面写的是草莓:12香草:5,那就更好了 有人能帮我吗?您首先要做的是在OpenCart扩展页面上查看是否有此功能的扩展。如果没有扩展,那么这就是您需要做的。1) 查找此信息所在的数据库表(我认为是它的产品)。然后在模型中查询它,将它传递给控制器,然后在视图中回显该变量/数组。我将为您大致提供所需的代码,但是您需要对其进行调整以满足您的需要。 这应该

我真的需要这个,因为我的大多数产品在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>