带有参数 Opencart 的负载控制器

Load Controller With Parameter Opencart

我在里面创建了一个控制器 catalog/controller/module/same_collection。php

里面:

class ControllerModuleSameCollection extends Controller {
        //User Product History
        public function index($product_id) {
           echo $product_id;
        } 
}

我试过像这样在另一个控制器中调用它 $data['same_color'] = $this->load->controller('module/same_color' ,['product_id' => 2]);

我尝试像这样使用 url 访问它

  mydomain.com/index.php?route=module/same_collection&product_id=2

但它不起作用。 请帮忙!!!

您似乎没有正确创建模块。确保您的模块设置保存在 module table 中。如果您的模块代码不在 table 中,那么您将不会在 index() 方法中获得任何参数。