How to get and set custom field of customer_group table Magento 2Magento 2 how to save custom field added in the form of customer group?Magento 2: Create customer group programaticallyMagento 2 hardcoded attribute setsMagento2 add custom address attributeMagento 2: How to override newsletter Subscriber modelMagento 2 Add new field to Magento_User admin formHow to manage custom attributes in group customerMagento 2: Plugin class does not existMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2 get custom attribute of a single product inside a plugin

How long can fsck take on a 30 TB volume?

How can I test a shell script in a "safe environment" to avoid harm to my computer?

if i accidentally leaked my schools ip address and someone d doses my school am i at fault

Was Mohammed the most popular first name for boys born in Berlin in 2018?

What's the "magic similar to the Knock spell" referenced in the Dungeon of the Mad Mage adventure?

Is there a need for better software for writers?

How does weapons training transfer to empty hand?

Is there an application which does HTTP PUT?

Are on’yomi words loanwords?

How do carbureted and fuel injected engines compare in high altitude?

What's the difference between "ricochet" and "bounce"?

Locked my sa user out

Why does the electron wavefunction not collapse within atoms at room temperature in gas, liquids or solids due to decoherence?

Probability of taking balls without replacement from a bag question

Examples where existence is harder than evaluation

Rusty Chain and back cassette – Replace or Repair?

Does Thread.yield() do anything if we have enough processors to service all threads?

Does a surprised creature obey the 1st level spell Command?

What is a good way to allow only one non null field in an object

Are wands in any sort of book going to be too much like Harry Potter?

Employee is self-centered and affects the team negatively

Using SUBSTRING and RTRIM Together

TeX Gyre Pagella Math Integral sign much too small

How did Captain Marvel know where to find these characters?



How to get and set custom field of customer_group table Magento 2


Magento 2 how to save custom field added in the form of customer group?Magento 2: Create customer group programaticallyMagento 2 hardcoded attribute setsMagento2 add custom address attributeMagento 2: How to override newsletter Subscriber modelMagento 2 Add new field to Magento_User admin formHow to manage custom attributes in group customerMagento 2: Plugin class does not existMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2 get custom attribute of a single product inside a plugin






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I create new extention and add some columns in customer_group table. but i can't get/set custom field.





namespace [NameSpace][Extension]BlockAdminhtmlGroupEdit;

use MagentoCustomerControllerRegistryConstants;
use MagentoTaxModelTaxClassSourceProduct as TaxProduct;

class Form extends MagentoCustomerBlockAdminhtmlGroupEditForm


protected $_taxProduct;

public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoFrameworkDataFormFactory $formFactory,
MagentoTaxModelTaxClassSourceCustomer $taxCustomer,
MagentoTaxModelTaxClassSourceProduct $taxProduct,
MagentoTaxHelperData $taxHelper,
MagentoCustomerApiGroupRepositoryInterface $groupRepository,
MagentoCustomerApiDataGroupInterfaceFactory $groupDataFactory,
array $data = []
)
$this->_taxCustomer = $taxCustomer;
$this->_taxProduct = $taxProduct;
$this->_taxHelper = $taxHelper;
$this->_groupRepository = $groupRepository;
$this->groupDataFactory = $groupDataFactory;
parent::__construct($context, $registry, $formFactory, $taxCustomer, $taxHelper, $groupRepository, $groupDataFactory, $data);


protected function _prepareLayout()

parent::_prepareLayout();
$form = $this->getForm();
$groupId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID);
/** @var MagentoCustomerApiDataGroupInterface $customerGroup */

if ($groupId === null)
$customerGroup = $this->groupDataFactory->create();
else
$customerGroup = $this->_groupRepository->getById($groupId);


$fieldset = $form->addFieldset('tax_classes', ['legend' => __('Tax Classes')]);

$fieldset->addField(
'tax_classes_shipping_tax_class',
'select',
[
'name' => 'tax_classes_shipping_tax_class',
'label' => __('Tax Class for Shipping'),
'title' => __('Tax Class for Shipping'),
'class' => '',
'required' => false,
'values' => $this->_taxProduct->toOptionArray(),
]
);

if($this->_backendSession->getCustomerGroupData())
$form->addValues($this->_backendSession->getCustomerGroupData());
$this->_backendSession->setCustomerGroupData(null);
else
/* print_r($customerGroup->getData());exit; */
$form->addValues($customerGroup->getData());







namespace [NameSpace][Extension]ControllerAdminhtmlGroup;

class Save extends MagentoCustomerControllerAdminhtmlGroupSave
MagentoBackendModelViewResultForward
*/
public function execute()

$taxClass = (int)$this->getRequest()->getParam('tax_class');

/** @var MagentoCustomerApiDataGroupInterface $customerGroup */
$customerGroup = null;
if ($taxClass)
$id = $this->getRequest()->getParam('id');
$resultRedirect = $this->resultRedirectFactory->create();
try
if ($id !== null)
$customerGroup = $this->groupRepository->getById((int)$id);
else
$customerGroup = $this->groupDataFactory->create();

$customerGroupCode = (string)$this->getRequest()->getParam('code');
if (empty($customerGroupCode))
$customerGroupCode = null;


$customerGroup->setCode($customerGroupCode);
$customerGroup->setTaxClassId($taxClass);
$data = $this->getRequest()->getParams();
$customerGroup->setData('tax_classes_shipping_tax_class',1);
$this->groupRepository->save($customerGroup);

$this->messageManager->addSuccess(__('You saved the customer group.'));
$resultRedirect->setPath('customer/group');
catch (Exception $e)
$this->messageManager->addError($e->getMessage());
if ($customerGroup != null)
$this->storeCustomerGroupDataToSession(
$this->dataObjectProcessor->buildOutputDataArray(
$customerGroup,
'MagentoCustomerApiDataGroupInterface'
)
);

$resultRedirect->setPath('customer/group/edit', ['id' => $id]);

return $resultRedirect;
else
return $this->resultForwardFactory->create()->forward('new');




I try


$customerGroup->getData() or $customerGroup->getCustomField() 
and

$customerGroup->setData('custom_field',1); 
$this->_groupRepository->save($customerGroup);


but fail.










share|improve this question



















  • 2





    can you please provide your code ?

    – Jaimin Parikh
    Jul 18 '16 at 4:43











  • i updated question. what miss here? Thank for help.

    – Dang Chung Duc
    Jul 18 '16 at 8:15











  • why you save the file value at MagentoCustomerBlockAdminhtmlGroupEditForm class... it not good idea

    – Amit Bera
    Jul 18 '16 at 8:26












  • No. I try save MagentoCustomerControllerAdminhtmlGroupSave::execute(). And i want $form->addValues($customerGroup->getData()); but fail.

    – Dang Chung Duc
    Jul 18 '16 at 8:30












  • Please share fulll code of` Form` and MagentoCustomerControllerAdminhtmlGroupSave:

    – Amit Bera
    Jul 18 '16 at 8:32


















2















I create new extention and add some columns in customer_group table. but i can't get/set custom field.





namespace [NameSpace][Extension]BlockAdminhtmlGroupEdit;

use MagentoCustomerControllerRegistryConstants;
use MagentoTaxModelTaxClassSourceProduct as TaxProduct;

class Form extends MagentoCustomerBlockAdminhtmlGroupEditForm


protected $_taxProduct;

public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoFrameworkDataFormFactory $formFactory,
MagentoTaxModelTaxClassSourceCustomer $taxCustomer,
MagentoTaxModelTaxClassSourceProduct $taxProduct,
MagentoTaxHelperData $taxHelper,
MagentoCustomerApiGroupRepositoryInterface $groupRepository,
MagentoCustomerApiDataGroupInterfaceFactory $groupDataFactory,
array $data = []
)
$this->_taxCustomer = $taxCustomer;
$this->_taxProduct = $taxProduct;
$this->_taxHelper = $taxHelper;
$this->_groupRepository = $groupRepository;
$this->groupDataFactory = $groupDataFactory;
parent::__construct($context, $registry, $formFactory, $taxCustomer, $taxHelper, $groupRepository, $groupDataFactory, $data);


protected function _prepareLayout()

parent::_prepareLayout();
$form = $this->getForm();
$groupId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID);
/** @var MagentoCustomerApiDataGroupInterface $customerGroup */

if ($groupId === null)
$customerGroup = $this->groupDataFactory->create();
else
$customerGroup = $this->_groupRepository->getById($groupId);


$fieldset = $form->addFieldset('tax_classes', ['legend' => __('Tax Classes')]);

$fieldset->addField(
'tax_classes_shipping_tax_class',
'select',
[
'name' => 'tax_classes_shipping_tax_class',
'label' => __('Tax Class for Shipping'),
'title' => __('Tax Class for Shipping'),
'class' => '',
'required' => false,
'values' => $this->_taxProduct->toOptionArray(),
]
);

if($this->_backendSession->getCustomerGroupData())
$form->addValues($this->_backendSession->getCustomerGroupData());
$this->_backendSession->setCustomerGroupData(null);
else
/* print_r($customerGroup->getData());exit; */
$form->addValues($customerGroup->getData());







namespace [NameSpace][Extension]ControllerAdminhtmlGroup;

class Save extends MagentoCustomerControllerAdminhtmlGroupSave
MagentoBackendModelViewResultForward
*/
public function execute()

$taxClass = (int)$this->getRequest()->getParam('tax_class');

/** @var MagentoCustomerApiDataGroupInterface $customerGroup */
$customerGroup = null;
if ($taxClass)
$id = $this->getRequest()->getParam('id');
$resultRedirect = $this->resultRedirectFactory->create();
try
if ($id !== null)
$customerGroup = $this->groupRepository->getById((int)$id);
else
$customerGroup = $this->groupDataFactory->create();

$customerGroupCode = (string)$this->getRequest()->getParam('code');
if (empty($customerGroupCode))
$customerGroupCode = null;


$customerGroup->setCode($customerGroupCode);
$customerGroup->setTaxClassId($taxClass);
$data = $this->getRequest()->getParams();
$customerGroup->setData('tax_classes_shipping_tax_class',1);
$this->groupRepository->save($customerGroup);

$this->messageManager->addSuccess(__('You saved the customer group.'));
$resultRedirect->setPath('customer/group');
catch (Exception $e)
$this->messageManager->addError($e->getMessage());
if ($customerGroup != null)
$this->storeCustomerGroupDataToSession(
$this->dataObjectProcessor->buildOutputDataArray(
$customerGroup,
'MagentoCustomerApiDataGroupInterface'
)
);

$resultRedirect->setPath('customer/group/edit', ['id' => $id]);

return $resultRedirect;
else
return $this->resultForwardFactory->create()->forward('new');




I try


$customerGroup->getData() or $customerGroup->getCustomField() 
and

$customerGroup->setData('custom_field',1); 
$this->_groupRepository->save($customerGroup);


but fail.










share|improve this question



















  • 2





    can you please provide your code ?

    – Jaimin Parikh
    Jul 18 '16 at 4:43











  • i updated question. what miss here? Thank for help.

    – Dang Chung Duc
    Jul 18 '16 at 8:15











  • why you save the file value at MagentoCustomerBlockAdminhtmlGroupEditForm class... it not good idea

    – Amit Bera
    Jul 18 '16 at 8:26












  • No. I try save MagentoCustomerControllerAdminhtmlGroupSave::execute(). And i want $form->addValues($customerGroup->getData()); but fail.

    – Dang Chung Duc
    Jul 18 '16 at 8:30












  • Please share fulll code of` Form` and MagentoCustomerControllerAdminhtmlGroupSave:

    – Amit Bera
    Jul 18 '16 at 8:32














2












2








2








I create new extention and add some columns in customer_group table. but i can't get/set custom field.





namespace [NameSpace][Extension]BlockAdminhtmlGroupEdit;

use MagentoCustomerControllerRegistryConstants;
use MagentoTaxModelTaxClassSourceProduct as TaxProduct;

class Form extends MagentoCustomerBlockAdminhtmlGroupEditForm


protected $_taxProduct;

public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoFrameworkDataFormFactory $formFactory,
MagentoTaxModelTaxClassSourceCustomer $taxCustomer,
MagentoTaxModelTaxClassSourceProduct $taxProduct,
MagentoTaxHelperData $taxHelper,
MagentoCustomerApiGroupRepositoryInterface $groupRepository,
MagentoCustomerApiDataGroupInterfaceFactory $groupDataFactory,
array $data = []
)
$this->_taxCustomer = $taxCustomer;
$this->_taxProduct = $taxProduct;
$this->_taxHelper = $taxHelper;
$this->_groupRepository = $groupRepository;
$this->groupDataFactory = $groupDataFactory;
parent::__construct($context, $registry, $formFactory, $taxCustomer, $taxHelper, $groupRepository, $groupDataFactory, $data);


protected function _prepareLayout()

parent::_prepareLayout();
$form = $this->getForm();
$groupId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID);
/** @var MagentoCustomerApiDataGroupInterface $customerGroup */

if ($groupId === null)
$customerGroup = $this->groupDataFactory->create();
else
$customerGroup = $this->_groupRepository->getById($groupId);


$fieldset = $form->addFieldset('tax_classes', ['legend' => __('Tax Classes')]);

$fieldset->addField(
'tax_classes_shipping_tax_class',
'select',
[
'name' => 'tax_classes_shipping_tax_class',
'label' => __('Tax Class for Shipping'),
'title' => __('Tax Class for Shipping'),
'class' => '',
'required' => false,
'values' => $this->_taxProduct->toOptionArray(),
]
);

if($this->_backendSession->getCustomerGroupData())
$form->addValues($this->_backendSession->getCustomerGroupData());
$this->_backendSession->setCustomerGroupData(null);
else
/* print_r($customerGroup->getData());exit; */
$form->addValues($customerGroup->getData());







namespace [NameSpace][Extension]ControllerAdminhtmlGroup;

class Save extends MagentoCustomerControllerAdminhtmlGroupSave
MagentoBackendModelViewResultForward
*/
public function execute()

$taxClass = (int)$this->getRequest()->getParam('tax_class');

/** @var MagentoCustomerApiDataGroupInterface $customerGroup */
$customerGroup = null;
if ($taxClass)
$id = $this->getRequest()->getParam('id');
$resultRedirect = $this->resultRedirectFactory->create();
try
if ($id !== null)
$customerGroup = $this->groupRepository->getById((int)$id);
else
$customerGroup = $this->groupDataFactory->create();

$customerGroupCode = (string)$this->getRequest()->getParam('code');
if (empty($customerGroupCode))
$customerGroupCode = null;


$customerGroup->setCode($customerGroupCode);
$customerGroup->setTaxClassId($taxClass);
$data = $this->getRequest()->getParams();
$customerGroup->setData('tax_classes_shipping_tax_class',1);
$this->groupRepository->save($customerGroup);

$this->messageManager->addSuccess(__('You saved the customer group.'));
$resultRedirect->setPath('customer/group');
catch (Exception $e)
$this->messageManager->addError($e->getMessage());
if ($customerGroup != null)
$this->storeCustomerGroupDataToSession(
$this->dataObjectProcessor->buildOutputDataArray(
$customerGroup,
'MagentoCustomerApiDataGroupInterface'
)
);

$resultRedirect->setPath('customer/group/edit', ['id' => $id]);

return $resultRedirect;
else
return $this->resultForwardFactory->create()->forward('new');




I try


$customerGroup->getData() or $customerGroup->getCustomField() 
and

$customerGroup->setData('custom_field',1); 
$this->_groupRepository->save($customerGroup);


but fail.










share|improve this question
















I create new extention and add some columns in customer_group table. but i can't get/set custom field.





namespace [NameSpace][Extension]BlockAdminhtmlGroupEdit;

use MagentoCustomerControllerRegistryConstants;
use MagentoTaxModelTaxClassSourceProduct as TaxProduct;

class Form extends MagentoCustomerBlockAdminhtmlGroupEditForm


protected $_taxProduct;

public function __construct(
MagentoBackendBlockTemplateContext $context,
MagentoFrameworkRegistry $registry,
MagentoFrameworkDataFormFactory $formFactory,
MagentoTaxModelTaxClassSourceCustomer $taxCustomer,
MagentoTaxModelTaxClassSourceProduct $taxProduct,
MagentoTaxHelperData $taxHelper,
MagentoCustomerApiGroupRepositoryInterface $groupRepository,
MagentoCustomerApiDataGroupInterfaceFactory $groupDataFactory,
array $data = []
)
$this->_taxCustomer = $taxCustomer;
$this->_taxProduct = $taxProduct;
$this->_taxHelper = $taxHelper;
$this->_groupRepository = $groupRepository;
$this->groupDataFactory = $groupDataFactory;
parent::__construct($context, $registry, $formFactory, $taxCustomer, $taxHelper, $groupRepository, $groupDataFactory, $data);


protected function _prepareLayout()

parent::_prepareLayout();
$form = $this->getForm();
$groupId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_GROUP_ID);
/** @var MagentoCustomerApiDataGroupInterface $customerGroup */

if ($groupId === null)
$customerGroup = $this->groupDataFactory->create();
else
$customerGroup = $this->_groupRepository->getById($groupId);


$fieldset = $form->addFieldset('tax_classes', ['legend' => __('Tax Classes')]);

$fieldset->addField(
'tax_classes_shipping_tax_class',
'select',
[
'name' => 'tax_classes_shipping_tax_class',
'label' => __('Tax Class for Shipping'),
'title' => __('Tax Class for Shipping'),
'class' => '',
'required' => false,
'values' => $this->_taxProduct->toOptionArray(),
]
);

if($this->_backendSession->getCustomerGroupData())
$form->addValues($this->_backendSession->getCustomerGroupData());
$this->_backendSession->setCustomerGroupData(null);
else
/* print_r($customerGroup->getData());exit; */
$form->addValues($customerGroup->getData());







namespace [NameSpace][Extension]ControllerAdminhtmlGroup;

class Save extends MagentoCustomerControllerAdminhtmlGroupSave
MagentoBackendModelViewResultForward
*/
public function execute()

$taxClass = (int)$this->getRequest()->getParam('tax_class');

/** @var MagentoCustomerApiDataGroupInterface $customerGroup */
$customerGroup = null;
if ($taxClass)
$id = $this->getRequest()->getParam('id');
$resultRedirect = $this->resultRedirectFactory->create();
try
if ($id !== null)
$customerGroup = $this->groupRepository->getById((int)$id);
else
$customerGroup = $this->groupDataFactory->create();

$customerGroupCode = (string)$this->getRequest()->getParam('code');
if (empty($customerGroupCode))
$customerGroupCode = null;


$customerGroup->setCode($customerGroupCode);
$customerGroup->setTaxClassId($taxClass);
$data = $this->getRequest()->getParams();
$customerGroup->setData('tax_classes_shipping_tax_class',1);
$this->groupRepository->save($customerGroup);

$this->messageManager->addSuccess(__('You saved the customer group.'));
$resultRedirect->setPath('customer/group');
catch (Exception $e)
$this->messageManager->addError($e->getMessage());
if ($customerGroup != null)
$this->storeCustomerGroupDataToSession(
$this->dataObjectProcessor->buildOutputDataArray(
$customerGroup,
'MagentoCustomerApiDataGroupInterface'
)
);

$resultRedirect->setPath('customer/group/edit', ['id' => $id]);

return $resultRedirect;
else
return $this->resultForwardFactory->create()->forward('new');




I try


$customerGroup->getData() or $customerGroup->getCustomField() 
and

$customerGroup->setData('custom_field',1); 
$this->_groupRepository->save($customerGroup);


but fail.







magento2 module customer-group






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 18 '16 at 8:41







Dang Chung Duc

















asked Jul 18 '16 at 3:58









Dang Chung DucDang Chung Duc

113




113







  • 2





    can you please provide your code ?

    – Jaimin Parikh
    Jul 18 '16 at 4:43











  • i updated question. what miss here? Thank for help.

    – Dang Chung Duc
    Jul 18 '16 at 8:15











  • why you save the file value at MagentoCustomerBlockAdminhtmlGroupEditForm class... it not good idea

    – Amit Bera
    Jul 18 '16 at 8:26












  • No. I try save MagentoCustomerControllerAdminhtmlGroupSave::execute(). And i want $form->addValues($customerGroup->getData()); but fail.

    – Dang Chung Duc
    Jul 18 '16 at 8:30












  • Please share fulll code of` Form` and MagentoCustomerControllerAdminhtmlGroupSave:

    – Amit Bera
    Jul 18 '16 at 8:32













  • 2





    can you please provide your code ?

    – Jaimin Parikh
    Jul 18 '16 at 4:43











  • i updated question. what miss here? Thank for help.

    – Dang Chung Duc
    Jul 18 '16 at 8:15











  • why you save the file value at MagentoCustomerBlockAdminhtmlGroupEditForm class... it not good idea

    – Amit Bera
    Jul 18 '16 at 8:26












  • No. I try save MagentoCustomerControllerAdminhtmlGroupSave::execute(). And i want $form->addValues($customerGroup->getData()); but fail.

    – Dang Chung Duc
    Jul 18 '16 at 8:30












  • Please share fulll code of` Form` and MagentoCustomerControllerAdminhtmlGroupSave:

    – Amit Bera
    Jul 18 '16 at 8:32








2




2





can you please provide your code ?

– Jaimin Parikh
Jul 18 '16 at 4:43





can you please provide your code ?

– Jaimin Parikh
Jul 18 '16 at 4:43













i updated question. what miss here? Thank for help.

– Dang Chung Duc
Jul 18 '16 at 8:15





i updated question. what miss here? Thank for help.

– Dang Chung Duc
Jul 18 '16 at 8:15













why you save the file value at MagentoCustomerBlockAdminhtmlGroupEditForm class... it not good idea

– Amit Bera
Jul 18 '16 at 8:26






why you save the file value at MagentoCustomerBlockAdminhtmlGroupEditForm class... it not good idea

– Amit Bera
Jul 18 '16 at 8:26














No. I try save MagentoCustomerControllerAdminhtmlGroupSave::execute(). And i want $form->addValues($customerGroup->getData()); but fail.

– Dang Chung Duc
Jul 18 '16 at 8:30






No. I try save MagentoCustomerControllerAdminhtmlGroupSave::execute(). And i want $form->addValues($customerGroup->getData()); but fail.

– Dang Chung Duc
Jul 18 '16 at 8:30














Please share fulll code of` Form` and MagentoCustomerControllerAdminhtmlGroupSave:

– Amit Bera
Jul 18 '16 at 8:32






Please share fulll code of` Form` and MagentoCustomerControllerAdminhtmlGroupSave:

– Amit Bera
Jul 18 '16 at 8:32











1 Answer
1






active

oldest

votes


















0














Magento till use Magic setter & getter method for save data of model.



namespace [YourNameSpace];

.....

use MagentoCustomerApiDataGroupInterface;

...

class [Your_Class] extends [Your_Extend]
protected $groupRepository;
public function __construct( ....
GroupRepositoryInterface $groupRepository, ......
) .....
parent::__construct(
.....
$groupRepository,
.......
);
$this->groupRepository = $groupRepository;


public function saveCustomfield()

$id = 'Customer_Group_id';
$customerGroup = $this->groupRepository->getById((int)$id);

$customerGroup->setData('fieldName',$your_Valur);

$this->groupRepository->save($customerGroup->getCode());







share|improve this answer

























  • I try and get error "Recoverable Error: Argument 1 passed to MagentoCustomerModelResourceModelGroupRepositoryInterceptor::save() must implement interface MagentoCustomerApiDataGroupInterface, string given"

    – Dang Chung Duc
    Jul 18 '16 at 8:18












  • @DangChungDuc , clear your generated directory

    – CompactCode
    Mar 29 '18 at 10:31











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f126088%2fhow-to-get-and-set-custom-field-of-customer-group-table-magento-2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Magento till use Magic setter & getter method for save data of model.



namespace [YourNameSpace];

.....

use MagentoCustomerApiDataGroupInterface;

...

class [Your_Class] extends [Your_Extend]
protected $groupRepository;
public function __construct( ....
GroupRepositoryInterface $groupRepository, ......
) .....
parent::__construct(
.....
$groupRepository,
.......
);
$this->groupRepository = $groupRepository;


public function saveCustomfield()

$id = 'Customer_Group_id';
$customerGroup = $this->groupRepository->getById((int)$id);

$customerGroup->setData('fieldName',$your_Valur);

$this->groupRepository->save($customerGroup->getCode());







share|improve this answer

























  • I try and get error "Recoverable Error: Argument 1 passed to MagentoCustomerModelResourceModelGroupRepositoryInterceptor::save() must implement interface MagentoCustomerApiDataGroupInterface, string given"

    – Dang Chung Duc
    Jul 18 '16 at 8:18












  • @DangChungDuc , clear your generated directory

    – CompactCode
    Mar 29 '18 at 10:31















0














Magento till use Magic setter & getter method for save data of model.



namespace [YourNameSpace];

.....

use MagentoCustomerApiDataGroupInterface;

...

class [Your_Class] extends [Your_Extend]
protected $groupRepository;
public function __construct( ....
GroupRepositoryInterface $groupRepository, ......
) .....
parent::__construct(
.....
$groupRepository,
.......
);
$this->groupRepository = $groupRepository;


public function saveCustomfield()

$id = 'Customer_Group_id';
$customerGroup = $this->groupRepository->getById((int)$id);

$customerGroup->setData('fieldName',$your_Valur);

$this->groupRepository->save($customerGroup->getCode());







share|improve this answer

























  • I try and get error "Recoverable Error: Argument 1 passed to MagentoCustomerModelResourceModelGroupRepositoryInterceptor::save() must implement interface MagentoCustomerApiDataGroupInterface, string given"

    – Dang Chung Duc
    Jul 18 '16 at 8:18












  • @DangChungDuc , clear your generated directory

    – CompactCode
    Mar 29 '18 at 10:31













0












0








0







Magento till use Magic setter & getter method for save data of model.



namespace [YourNameSpace];

.....

use MagentoCustomerApiDataGroupInterface;

...

class [Your_Class] extends [Your_Extend]
protected $groupRepository;
public function __construct( ....
GroupRepositoryInterface $groupRepository, ......
) .....
parent::__construct(
.....
$groupRepository,
.......
);
$this->groupRepository = $groupRepository;


public function saveCustomfield()

$id = 'Customer_Group_id';
$customerGroup = $this->groupRepository->getById((int)$id);

$customerGroup->setData('fieldName',$your_Valur);

$this->groupRepository->save($customerGroup->getCode());







share|improve this answer















Magento till use Magic setter & getter method for save data of model.



namespace [YourNameSpace];

.....

use MagentoCustomerApiDataGroupInterface;

...

class [Your_Class] extends [Your_Extend]
protected $groupRepository;
public function __construct( ....
GroupRepositoryInterface $groupRepository, ......
) .....
parent::__construct(
.....
$groupRepository,
.......
);
$this->groupRepository = $groupRepository;


public function saveCustomfield()

$id = 'Customer_Group_id';
$customerGroup = $this->groupRepository->getById((int)$id);

$customerGroup->setData('fieldName',$your_Valur);

$this->groupRepository->save($customerGroup->getCode());








share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 18 '16 at 8:59









Jaimin Parikh

2,0982626




2,0982626










answered Jul 18 '16 at 7:11









Amit BeraAmit Bera

60.5k1678178




60.5k1678178












  • I try and get error "Recoverable Error: Argument 1 passed to MagentoCustomerModelResourceModelGroupRepositoryInterceptor::save() must implement interface MagentoCustomerApiDataGroupInterface, string given"

    – Dang Chung Duc
    Jul 18 '16 at 8:18












  • @DangChungDuc , clear your generated directory

    – CompactCode
    Mar 29 '18 at 10:31

















  • I try and get error "Recoverable Error: Argument 1 passed to MagentoCustomerModelResourceModelGroupRepositoryInterceptor::save() must implement interface MagentoCustomerApiDataGroupInterface, string given"

    – Dang Chung Duc
    Jul 18 '16 at 8:18












  • @DangChungDuc , clear your generated directory

    – CompactCode
    Mar 29 '18 at 10:31
















I try and get error "Recoverable Error: Argument 1 passed to MagentoCustomerModelResourceModelGroupRepositoryInterceptor::save() must implement interface MagentoCustomerApiDataGroupInterface, string given"

– Dang Chung Duc
Jul 18 '16 at 8:18






I try and get error "Recoverable Error: Argument 1 passed to MagentoCustomerModelResourceModelGroupRepositoryInterceptor::save() must implement interface MagentoCustomerApiDataGroupInterface, string given"

– Dang Chung Duc
Jul 18 '16 at 8:18














@DangChungDuc , clear your generated directory

– CompactCode
Mar 29 '18 at 10:31





@DangChungDuc , clear your generated directory

– CompactCode
Mar 29 '18 at 10:31

















draft saved

draft discarded
















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f126088%2fhow-to-get-and-set-custom-field-of-customer-group-table-magento-2%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form