Attribute Model Represents the attribute in the database form, its logic is standard across all attributes and is difficult to change. If the attribute doesnât exist originally and its new value is not empty it inserts. We can debug which field has got the null value by placing a logger just before passing the value to validateLength function in the file vendor/magento/module-eav/Model/Attribute/Data/Text. If the attribute exist originally but its new value is set to empty it deletes. $customerSetup->getEavConfig()->getAttribute(\Magento\Customer\Model\Customer::ENTITY, 'department') $customerSetup->getEavConfig()->getAttribute(\Magento\Customer\Model\Customer::ENTITY, 'company') \Magento\Customer\Model\Customer::ENTITY, $this->salesSetupFactory = $salesSetupFactory $this->customerSetupFactory = $customerSetupFactory $this->messageManager->addError($e->getMessage()) Īnd this is the code I used to created Company and Department attributeĪpp/code/Test/Test1/Setup/InstallData.php eavSetupFactory = $eavSetupFactory $this->customerRepository->save($customer) $customer->setCustomAttribute('department', $department) $customer->setCustomAttribute('company', $company) $customer = $this->customerRepository->getById($customerId) $customerId = $this->customerSession->getCustomer()->getId() when I entered any value in edit form, it is saved in adimn form but not visible on frontend. $email = $this->getRequest()->getParam('email_hidden') I am using magento 2.1.0, I created custom attribute of customer, and add field on frontend in customer edit information form. $department = $this->getRequest()->getParam('department') $company = $this->getRequest()->getParam('company') $resultRedirect->setUrl('./././customer/account/edit') Then do a full re-index and the attribute should now be available within your product list templates. Then change Used in Product Listing to Yes. Admin > Catalog > Attributes > Manage Attributes > find your Stock Due Date attribute. $resultRedirect = $this->resultRedirectFactory->create() Hi ethantram, If you set the attribute to be available in product listing via. $this->customerFactory = $customerFactory Next up is our di.xml again, living in etc directory. The type in this case can reference either a PHP type or a class type. The next line defines our attributes.$this->customerRepository = $customerRepository As weâre doing this for a product, weâll need to use the Magento\Catalog\Api\Data\ProductInterface interface. I got this error when trying to save custom data to customer,Ĥ3766 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught TypeError: Argument 2 passed to Magento\Eav\Model\Attribute\Data\Text::validateLength() must be of the type string, null givenĪpp/code/Test/Customer/Controller/Account/EditPost.php customerSession = $customerSession
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |