Magento2 如何在Collection _initSelect方法中获取客户ID?

我想要_initselect方法中的customerId 。我该如何实现?

protected function _initSelect()
{
    parent::_initSelect();
    $this->getSelect()->joinLeft(
        ['cp1' => $this->getTable('2checkout_ins')],
        'cp1.id =main_table.two_checkout_message_id OR cp1.id = NULL',
        ['main_table.increment_id','main_table.from_date','main_table.subscription_period','main_table.to_date','main_table.renew_date','main_table.status_success','main_table.customer_id','main_table.paypal_id','main_table.two_checkout_message_id','final_amount'=>'cp1.invoice_usd_amount']
        )->joinLeft(
        ['cp2' => $this->getTable('paypal_result')],
        'main_table.paypal_id = cp2.id OR cp2.id = NULL',
        ['final_amount_paypal'=>'cp2.amount']
        );
        return $this;
    }

请检查下面的图像:

回答:

使用\Magento\Backend\Model\SessionFactory $adminsession 并获取

$admin =  $this->adminsession->create();
$customerData=$admin->getData();
return $customerData['customer_data']['customer_id'];

相关文章

0 0 投票数
文章评分
订阅评论
提醒
0 评论
最旧
最新 最多投票
内联反馈
查看所有评论