如何以编程方式在“订单网格”中基于“自定义属性”应用过滤器

时间:2019-02-20 13:14:56

标签: magento2

我将custom_attribute(current_seller_id)保存在sales_order和sales_order_grid中,并且在两个表的列中都保存了相同的值。下面给出了用于sales_order代码中的节省值的信息。在该发货单和报价之前,我什至使用了sales_model_service_quote_submit_sub

public function execute(\Magento\Framework\Event\Observer $observer)
{
    $order = $observer->getData('order');
    $quote = $observer->getData('quote');
    $quoteItems = $quote->getItems();
    foreach ($quoteItems as $quoteItem){
        if ($quoteItem->getCurrentSellerId() != ""){
            $items[]=$quoteItem->getCurrentSellerId();
        }
    }
    $seller_ids=implode(',',$items);
    $order->setCurrentSellerId($seller_ids);
    return $this;
}

现在我想基于自己的custom_attribute(current_seller_id)应用condition(Filter)例如,如果具有current_seller_id的卖方为2,则只需在订单网格中显示这些记录,其值为2。我将获得当前的管理员ID通过“ \ Magento \ Backend \ Model \ Auth \ Session $ authSession

0 个答案:

没有答案