Alternative to CustomCustomerAttributes for storing related data?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 лет назад
Hello.  I have a need to associate data that may have nothing to do with a customers UI / experience.  For example I need to associate one NOP customer with various internal accounts in the form of Div and Account numbers.  The below will not exactly be efficient to use when it grows ... and is needed in external applications.

CustomCustomerAttributes

<Attributes><CustomerAttribute ID="1"><CustomerAttributeValue><Value>11</Value></CustomerAttributeValue></CustomerAttribute><CustomerAttribute ID="2"><CustomerAttributeValue><Value>7777777</Value></CustomerAttributeValue></CustomerAttribute></Attributes>


The account relationship will be needed often for internal operations and we will be creating an admin interface our CSR's will use ALL THE TIME = most of their day to place orders from NOP into our ERP system.  We are highly regulated and must scruntize every order.

Then we will need to update NOP's sales orders with our sales orders and on and on... We REALLY could use a way to cleanly store extended customer data.  I would love to define data types as well but will gladly give it up if we could use NOP to manage these extra needed data fields

Otherwise, the alternative question would be: can I add columns to NOP Customer table without any ill effects...

Thanks SO MUCH!!
7 лет назад
My apologies; did I post this question in the wrong area?

In any case, doing the below as SQL data for external apps (to help tie NOP to external apps) seems less than elegant.  I would like to know a more solid way that folks have addressed this... just add a custom table in NOP db?  Or...?


<Attributes><CustomerAttribute ID="1"><CustomerAttributeValue><Value>asdf1234</Value></CustomerAttributeValue></CustomerAttribute><CustomerAttribute ID="2"><CustomerAttributeValue><Value>5678gyuij</Value></CustomerAttributeValue></CustomerAttribute><CustomerAttribute ID="4"><CustomerAttributeValue><Value>bdfsafws3fva3ws</Value></CustomerAttributeValue></CustomerAttribute><CustomerAttribute ID="5"><CustomerAttributeValue><Value>5</Value></CustomerAttributeValue></CustomerAttribute></Attributes><CustomerAttribute ID="6"><CustomerAttributeValue><Value>thisTestValue</Value></CustomerAttributeValue></CustomerAttribute><CustomerAttribute ID="7"><CustomerAttributeValue><Value>moarTest</Value></CustomerAttributeValue></CustomerAttribute><CustomerAttribute ID="9"><CustomerAttributeValue><Value>ThisIsRidiculous</Value></CustomerAttributeValue></CustomerAttribute>
7 лет назад
You almost certainly don't want to use custom customer attributes since by default they're visible to, and editable by, the customer; so not really suitable for storing info that's only meant for admin or programmatic use. Some other options in order of least to most effort:

1. Borrow some unused columns from the existing Customer table
For example, if you you don't use usernames on your site you could borrow the existing username field to maintain some other piece of information. I can't think of any other fields that you can reliably borrow and it sounds like you already have plans for multiple fields so probably not an option.

2. Add some extra columns to the existing Customer table
There's nothing to stop you adding some columns and this can work if you only access/manage these values outside of nop such as in SQL queries or some external application. You'd have to be careful about future updates to make sure there isn't something in the SQL upgrade script that would drop your extra columns. If you wanted the values to be available to nop then you'd need to make edits to the nop core code and services which is generally a bad idea if you want to be able to upgrade easily in future.

3. Use generic attributes
Have a look in the GenericAttribute table in the database. You'll see a bunch of properties associated to customers that aren't in the Customer table - some of these are editable via the nop GUI (such as customer names) and some are only used in code. Nop provides methods in the GenericAttributeService.cs for setting, updating and accessing these values.

4. Add your own table with a relationship back to the CustomerId
Probably the best option if you're planning to build some sort of plugin to provide a GUI in nop to edit these properties.
7 лет назад
Thanks very much Pete!  I really appreciate your reply and will analyze those options you sent my way, thanks!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.