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

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

Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?