Skip to content

Getting group id from customer session returns wrong data type. #14055

@bydrei

Description

@bydrei

If you get the customer from the session and then get the group id, the group id is returned as a string. The return type for that function specifies it should be of type int but it is returning as a string.

Preconditions

  1. Magento 2.1.12
  2. PHP 7.0.27
  3. MySQL 5.7.21

Steps to reproduce

$customer = $this->customerSession->getCustomer();
$groupId  = $customer->getGroupId();

Expected result

$groupId should be of type int and not a string.

Actual result

$groupId is returned as a string instead of an int as the function phpDoc specifies.

/**
     * Retrieve customer group identifier
     *
     * @return int
     */
    public function getGroupId()
    {
        if (!$this->hasData('group_id')) {
            $storeId = $this->getStoreId() ? $this->getStoreId() : $this->_storeManager->getStore()->getId();
            $groupId = $this->_scopeConfig->getValue(
                GroupManagement::XML_PATH_DEFAULT_ID,
                ScopeInterface::SCOPE_STORE,
                $storeId
            );
            $this->setData('group_id', $groupId);
        }
        return $this->getData('group_id');
    }

Metadata

Metadata

Labels

Issue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passednon-issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions