18 votes
Accepted

Magento2 How to get customer group name by using group id?

If you have group id then add below code at your block class protected $groupRepository; public function __construct( ... \Magento\Customer\Api\GroupRepositoryInterface $groupRepository, ...
Amit Bera's user avatar
  • 77.5k
15 votes
Accepted

Updating customer group from observer on customer_register_success event?

First create your configuration file in Vendor\Module\etc\frontend\events.xml : <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
Raphael at Digital Pianism's user avatar
15 votes
Accepted

Magento 2: How to get customer collection

1) Use \Magento\Customer\Model\ResourceModel\Customer\CollectionFactory class to get customer collection <?php protected $_customerFactory; public function __construct( ... \Magento\...
Prince Patel's user avatar
  • 22.7k
11 votes

How to get current customer group id in magento2

By default, Magento will clear the customer session: \Magento\PageCache\Model\Layout\DepersonalizePlugin::afterGenerateXml. https://magento.stackexchange.com/a/92133/33057 Take a look: vendor/...
Khoa TruongDinh's user avatar
9 votes
Accepted

Get all customer groups

You can use below mentioned code run it from your magento dir: <?php error_reporting(E_ALL | E_STRICT); $mageFilename = 'app/Mage.php'; require_once $mageFilename; Mage::setIsDeveloperMode(true); ...
Arunendra's user avatar
  • 7,446
9 votes

Magento 2: Create customer group programatically

Save method is deprecated in Magento 2 try this code: <?php /** * Copyright © 2018 MyCompany. All rights reserved. * See COPYING.txt for license details. */ namespace MyCompany\MyModule\Setup; ...
Mohamed El Mrabet's user avatar
9 votes
Accepted

Magento 2 override the cutomer account loginpost controller

You need to rewrite the customer loginPost plugin file as per the below <?php namespace VENDOR\MYMODULENAME\Plugin\Customer; class LoginPost { public function __construct( \Magento\...
lavanya's user avatar
  • 199
8 votes

How to get current customer group id in magento2

you can get group Id by following code protected $_customerSession; public function __construct( .... \Magento\Customer\Model\Session $customerSession, .... ) { ...
Qaisar Satti's user avatar
  • 32.5k
7 votes
Accepted

Add customer to group when registering

There is two way to achieve this functionality : Call the event customer_register_success and change the user group just after registration. Follow this solution : Set customer group from customer ...
Ashish Jagnani's user avatar
7 votes

Magento 2: Create customer group programatically

Since the version 2.2.1 the use of the ->save() method from the Magento\Customer\Model\Group implementations has been deprecated. Instead, you should use: use Magento\Customer\Api\Data\...
Matias Nombarasco's user avatar
6 votes
Accepted

Magento 1.9 Observer - How to disable Payment method in Observer?

I tried this on a vanilla installation of Magento 1.9.3.6 Below are the files. app/code/local/Gta/FindPaymentGateway/etc/config.xml <?xml version="1.0"?> <config> <modules> ...
Sukeshini's user avatar
  • 9,955
6 votes
Accepted

Display Customer Groups Dropdown in admin system configurations in custom module of Magento 2

Here is the code which I have used in my custom module. Hope this will also help you. Add below code in Vendor/Module/etc/adminhtml/system.xml file. <?xml version="1.0"?> <...
Ronak Parmar's user avatar
5 votes
Accepted

Display Static Block for a Customer Group

You can use below code to show static block for particular customer group if customer is logged In. /* Check if customer is logged in */ $isLoggedIn = Mage::getSingleton('customer/session')-&...
Kul's user avatar
  • 1,777
5 votes
Accepted

Magento 2: Programmatically create & apply shopping cart rule

According to the best practices in Magento 2 you need to use Repositories to create/save entities. However, there are still some issues with repositories for particular entities, including the ...
Yaroslav Rogoza's user avatar
5 votes
Accepted

Magento 2 plugin for sending email when change customer's group

To send an email when customer group changes, I will recommend using events instead of using plugin. Why not recommending plugin for this kind of task ? Because we use plugin when we need to modify ...
amitshree's user avatar
  • 7,006
4 votes

Magento 2: How to display all Customer Group Price on Product Detail Page

Below is the way to get /** @var \Magento\Catalog\Pricing\Render\FinalPriceBox $block */ $productId = $block->getSaleableItem()->getId(); // START $objectManager = \Magento\Framework\App\...
Jackson's user avatar
  • 9,909
4 votes
Accepted

Custom field in Customer group

First you have to add column 'customer_group_plan_price' in table customer_group_plan_price so need to change line in Form.php $fs->addField('customer_group_plan_price', 'text', array( ...
Arshad Muhammad's user avatar
4 votes

Magento 2.1 set group ID on a custom registration form

This is not the only issue in Magento Custom registration form , also the issue exists in Default registration form.If we passing any group_id from default registration form then that customer group ...
Amit Bera's user avatar
  • 77.5k
4 votes

Magento2 How to get customer group name by using group id?

Update your block: /** * @var \Magento\Customer\Api\GroupRepositoryInterface */ protected $groupRepository; /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \...
Siarhey Uchukhlebau's user avatar
4 votes
Accepted

Create Link Dynamically By Customer Group in Customer Account Navigation - Magento 2

Create a module and add create customer_account.xml like below: app/code/Vendor/Module/view/frontend/layout/customer_account.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/...
Sukumar Gorai's user avatar
4 votes

Error showing special prices when changing store view - Magento 2.3.1

Hey Please check in catalog_product_index_price table with your entity_id. Like SELECT * FROM catalog_product_index_price WHERE entity_id =432 LIMIT 0 , 30 and see what price is there.
Krunal Pandya's user avatar
3 votes

Get all customer groups

Use following function $groups = Mage::getModel('customer/group')->getCollection(); foreach ($groups as $Group) { echo 'Customer GroupID = '.$Group->getCustomerGroupId().'<br>'; echo ...
Rohit Kundale's user avatar
3 votes
Accepted

Duplicate Product Group Price

I have the same issue after upgrade to 1.9.3.2. I think it's a core bug that is related to the new group price attribute is_percent. Here is a hotfix that I use: EDITED: app/design/adminhtml/default/...
MarekW's user avatar
  • 46
3 votes
Accepted

Add multiple customer Group IDs in some code - Magento 1.9

Add them to an array, and use the PHP function in_array: <?php $customerSession = Mage::getSingleton('customer/session'); $hideGroupIds = array(6, 8, 9); if ($customerSession->isLoggedIn() &...
Danny Nimmo's user avatar
  • 1,243
3 votes

How to get current customer group id in magento2

Try this to get the current customer group Id and name for both logged and not logged-in customers. protected $_customerSession; protected $_customerGroupCollection; public function __construct( ...
Prince Patel's user avatar
  • 22.7k
3 votes

Magento 2 get specific customer group customers list

Create Block file in module Customer.php Path : App\Code\{CompanyName}\{ModuleName}\Block\Bookseller\ <?php namespace {CompanyName}\{ModuleName}\Block\Bookseller; class Customer extends \Magento\...
Baharuni Asif's user avatar
3 votes

Magento2 How to get customer group name by using group id?

You should not make such requests in template files. Use blocks for it. Add \Magento\Customer\Api\GroupRepositoryInterface $groupRepository to the block. And get group object like /** * Customer ...
Pavel Novitsky's user avatar
3 votes
Accepted

How to get customer group in custom module admin page forms in magento 2?

Thank you for attempting me to help in this. Here what i missed is not correctly trying to access my getOptionArray2() function in main.php from grid.php. I fixed this with some changes in my code. I ...
Mujahidh's user avatar
  • 2,793
3 votes
Accepted

Add new registration form magento 2

create wholesalerregistration.phtml file app\code\vendor\Module\view\frontend\templates\wholesalerregistration.phtml <?= $block->getChildHtml('form_fields_before') ?> <?php /* Extensions ...
Sweety Masmiya's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible