Php Prestashop 1.7.x-如何添加产品&x27;产品列表中有哪些承运商?

Php Prestashop 1.7.x-如何添加产品&x27;产品列表中有哪些承运商?,php,prestashop,Php,Prestashop,今天,我在我的产品上添加了视觉标签,以便向用户显示哪些运营商可以使用,这样他们就不会有一辆车,车上有10种产品交付,1种产品在店内提货。 他们会马上知道自己能做什么 在单个产品页面上没有问题,在ProductController.php中添加这个就足够了: $this->context->smarty->assign(array( 'pictures' => $pictures, 'textFields' => $te

今天,我在我的产品上添加了视觉标签,以便向用户显示哪些运营商可以使用,这样他们就不会有一辆车,车上有10种产品交付,1种产品在店内提货。 他们会马上知道自己能做什么

在单个产品页面上没有问题,在ProductController.php中添加这个就足够了:

$this->context->smarty->assign(array(
            'pictures' => $pictures,
            'textFields' => $text_fields,
            'carriers' => $this->product->getCarriers(),
            ));
重点是产品列表页面。。。我似乎无法找出我能做些什么来将运营商与该类别的每种产品联系起来

通过查看ProductListingFrontController.php,我注意到我可以在这里获得$variables中的所有类别产品:

protected function doProductSearch($template, $params = array(), $locale = null)
{
    if ($this->ajax) {
        ob_end_clean();
        header('Content-Type: application/json');
        $this->ajaxRender(json_encode($this->getAjaxProductSearchVariables()));

        return;
    } else {
        $variables = $this->getProductSearchVariables();

有人在Prestashop 1.7.x中做过类似的事情吗?

我建议您构建一个非常好的应用程序,并利用原生Prestashop钩子displayProductListReviewsdisplayProductAdditionalInfo返回您想要的内容

您可以轻松访问hook$params中的所有产品属性,以获得可用的载体