Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

[My Account] Add support of Customer attributes #271

Closed
naydav opened this issue Dec 10, 2018 · 6 comments
Closed

[My Account] Add support of Customer attributes #271

naydav opened this issue Dec 10, 2018 · 6 comments

Comments

@naydav
Copy link
Contributor

naydav commented Dec 10, 2018

AC:

  • Validation should be based on attributes(EAV) rules (for details see eav_attribute table)
    Now validation of Customer address data is hardcoded in
    \Magento\CustomerGraphQl\Model\Customer\UpdateCustomerData::execute
  • Support for a case when an attribute is required and value is 0(zero)
  • Only related to Frontend attributes could be loaded/created/updated
  • Possibility to update partial data
  • Functionality is covered by API-function tests
@naydav naydav added this to the Release: 2.3.1 milestone Dec 10, 2018
@naydav naydav changed the title Add validation for Customer attributes Add validation for Customer attributes during creating/updating Dec 10, 2018
@naydav naydav changed the title Add validation for Customer attributes during creating/updating Add support of Customer attributes Dec 10, 2018
@naydav naydav changed the title Add support of Customer attributes [My Account] Add support of Customer attributes Dec 12, 2018
@furseyev furseyev self-assigned this Feb 20, 2019
@naydav naydav modified the milestones: Release: 2.3.2, Release: 2.3.3 Feb 20, 2019
@naydav
Copy link
Contributor Author

naydav commented Mar 15, 2019

Hello @furseyev
Are you still working on the task?

@furseyev
Copy link
Contributor

Hell @naydav ,

I've done the implementation in the https://github.com/magento/graphql-ce/tree/feature/271-Customer-Attributes-Support branch and needed only to add api functional tests for those.

However, merging the latest changes from 2.3-develop shows a merge conflict - one of the models I've changed is already removed, so need to figure that out and re-do the solution.

Thanks!

furseyev added a commit that referenced this issue Mar 16, 2019
- Customer attributes validation added
furseyev added a commit that referenced this issue Mar 16, 2019
- Updating API functional test: adding
furseyev added a commit that referenced this issue Mar 16, 2019
- Customer attributes validation added for create customer action
furseyev added a commit that referenced this issue Mar 16, 2019
- Updating API functional test: adding empty first name scenario for customer account creation API
@furseyev
Copy link
Contributor

Hello @naydav ,

Any updates on this one? PR was created 11 days ago: #489
This comment is just for bumping task up. Please let me know if some labels/etc are missing.

Thanks!

@TomashKhamlai
Copy link
Contributor

@naydav, please check this information and clarify requirements if needed.

Preconditions:
Custom Module that extends Customers attributes
OR
Magento EE (Customer attributes can be configured out of the box)

Steps:

  1. Create attribute (Magento EE)
  • Default Label and Attribute Code: a_experimental_field
  • Input Type: Text Field
  • Values Required: Yes
  • Input Validation: Length Only
  • Minimum Text Length: 3
  • Maximum Text Length: 65
  • Show on Storefront: Yes
  • Sort Order: 0
  • Forms to Use In: Customer Registration and Customer Account Edit
  1. Save attribute and verify that attribute was added to specified forms. Perform reindex and flush cache in case you are in production mode and verify again.
  2. First try this way:
mutation {
  createCustomer(
    input: {
      firstname: "User"
      lastname: "Attributed"
      email: "[email protected]"
      password: "123123qA"
      a_experimental_field: "abcdefghe"
    }
  ) {
    customer {
      firstname
      lastname
      email
    }
  }
}

and get this

{
  "errors": [
    {
      "message": "Field \"a_experimental_field\" is not defined by type CustomerInput.",
      "category": "graphql",
      "locations": [
        {
          "line": 2,
          "column": 125
        }
      ]
    }
  ]
}
  1. Then try this way
mutation {
  createCustomer(
    input: {
      firstname: "User"
      lastname: "Attributed"
      email: "[email protected]"
      password: "123123qA"
    }
  ) {
    customer {
      firstname
      lastname
      email
    }
  }
}

and get next error in Network tab of Electron Dev Tools (Chrome Dev Tools)

{"errors":[{"debugMessage":"Argument 2 passed to Magento\\Eav\\Model\\Attribute\\Data\\Text::validateLength() must be of the type string, null given, called in \/shared\/httpd\/graphql-ee\/graphql-ee\/app\/code\/Magento\/Eav\/Model\/Attribute\/Data\/Text.php on line 80","message":"Internal server error","category":"internal","locations":[{"line":2,"column":3}],"path":["createCustomer"]}],"data":{"createCustomer":null}}<br />
<b>Fatal error</b>:  Uncaught Exception: User Error: Some transactions have not been committed or rolled back in /shared/httpd/graphql-ee/graphql-ee/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php on line 3980 in /shared/httpd/graphql-ee/graphql-ee/lib/internal/Magento/Framework/App/ErrorHandler.php:61
Stack trace:
#0 [internal function]: Magento\Framework\App\ErrorHandler-&gt;handler(256, 'Some transactio...', '/shared/httpd/g...', 3980, Array)
#1 /shared/httpd/graphql-ee/graphql-ee/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php(3980): trigger_error('Some transactio...', 256)
#2 [internal function]: Magento\Framework\DB\Adapter\Pdo\Mysql-&gt;__destruct()
#3 {main}
  thrown in <b>/shared/httpd/graphql-ee/graphql-ee/lib/internal/Magento/Framework/App/ErrorHandler.php</b> on line <b>61</b><br />

image

@naydav
Copy link
Contributor Author

naydav commented May 30, 2019

Looks like we need to add attributes dynamically

Example
<virtualType name="Magento\Framework\GraphQlSchemaStitching\Reader" type="Magento\Framework\GraphQlSchemaStitching\Common\Reader">

@naydav
Copy link
Contributor Author

naydav commented May 30, 2019

My proposal is split functionality in two PR
First (already created by @furseyev) - with attributes which were added during installation
Second - with a possibility to add attributes dynamically via admin panel (example in a comment above)

@TomashKhamlai please confirm that functionality (first PR) is valid for already existent attributes
Thanks

furseyev added a commit that referenced this issue Jun 22, 2019
furseyev added a commit that referenced this issue Jun 22, 2019
furseyev added a commit that referenced this issue Jul 9, 2019
furseyev added a commit that referenced this issue Jul 18, 2019
@naydav naydav modified the milestones: Release: 2.3.3, Release: 2.3.4 Aug 1, 2019
magento-engcom-team added a commit that referenced this issue Aug 16, 2019
 - Merge Pull Request #489 from magento/graphql-ce:feature/271-Customer-Attributes-Validation
 - Merged commits:
   1. dba9800
   2. 7f6718d
   3. 3735e91
   4. 342675a
   5. e177801
   6. 9b5b0a1
   7. 9f1ba1a
   8. 670116c
   9. 40e2363
   10. d071027
   11. b4db736
   12. 4b7acdc
   13. 48f1891
   14. 3641627
   15. ef078b6
   16. 1c65121
   17. cc69055
   18. 7ee6a1a
   19. f358267
   20. eb48f44
   21. 2eb7c15
   22. 7ca7acc
   23. 1c30336
   24. 4382c3a
   25. da8d6ac
   26. 0b4c496
   27. 5ae0633
@lenaorobei lenaorobei reopened this Aug 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants