Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.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
Mysql Magento 2-选择时,组_concat位于左侧连接处_Mysql_Magento2 - Fatal编程技术网

Mysql Magento 2-选择时,组_concat位于左侧连接处

Mysql Magento 2-选择时,组_concat位于左侧连接处,mysql,magento2,Mysql,Magento2,我目前正在尝试将订单产品中的SKU放入订单网格,并在后端进行筛选。它已在运行,但仅适用于一个SKU,而不是订单中的所有SKU。我的控制器如下所示: <?php namespace Vendor\Module\Model\ResourceModel\Order\Grid; use Magento\Sales\Model\ResourceModel\Order\Grid\Collection as OriginalCollection; use Magento\Framework\Data\

我目前正在尝试将订单产品中的SKU放入订单网格,并在后端进行筛选。它已在运行,但仅适用于一个SKU,而不是订单中的所有SKU。我的控制器如下所示:

<?php
namespace Vendor\Module\Model\ResourceModel\Order\Grid;

use Magento\Sales\Model\ResourceModel\Order\Grid\Collection as OriginalCollection;
use Magento\Framework\Data\Collection\Db\FetchStrategyInterface as FetchStrategy;
use Magento\Framework\Data\Collection\EntityFactoryInterface as EntityFactory;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Psr\Log\LoggerInterface as Logger;

class Collection extends OriginalCollection
{
    protected $_authSession;
    public function __construct(
       EntityFactory $entityFactory,
       Logger $logger,
       FetchStrategy $fetchStrategy,
       EventManager $eventManager,
       \Magento\Backend\Model\Auth\Session $authSession
      )
    {        
       $this->_authSession = $authSession;
       parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager);
    }

    protected function _renderFiltersBefore() {
        $user = $this->_authSession->getUser();
        $joinTable = $this->getTable('sales_order_item');
        $this->getSelect()->joinLeft($joinTable, 'main_table.entity_id = sales_order_item.order_id', ['sku'])->group('entity_id');
        parent::_renderFiltersBefore();
    }
}

但它不起作用。

我自己解决了。缺少的是GROUPBY语句,所以我在查询中添加了->GROUP'entity\u id'。我还掉了分离器

$this->getSelect()->joinLeft($joinTable, 'main_table.entity_id = sales_order_item.order_id', ['sku' => new \Zend_Db_Expr('group_concat(`sales_order_item`.sku)')])->group('entity_id');

我自己解决了。缺少的是GROUPBY语句,所以我在查询中添加了->GROUP'entity\u id'。我还掉了分离器

$this->getSelect()->joinLeft($joinTable, 'main_table.entity_id = sales_order_item.order_id', ['sku' => new \Zend_Db_Expr('group_concat(`sales_order_item`.sku)')])->group('entity_id');