문제

How to get customer group id into graphql magento2

Note: Only in GraphQL

도움이 되었습니까?

해결책

Not much clear what you are looking for. If you want to get the customer group_id in customer graphql query you can directly provide the output variable as below.

{
  customer {
    firstname
    lastname
    suffix
    email
    group_id
  }
}

다른 팁

Note: This only you'll get if customer is logged in in your Model Resolver file:

protected $_customerSession;

public function __construct(
    \Magento\Customer\Model\Session $customerSession,
) {
    $this->_customerSession = $customerSession;
}

public function getGroupId(){
if($this->_customerSession->isLoggedIn()):
    $customerGroupId = $this->_customerSession->getCustomer()->getGroupId();
endif;
}

After this you can set $customerGroupId variable as a array of your module.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top