Help creating a "organization plugin" #2551
Unanswered
matteoxplo
asked this question in
Q&A
Replies: 1 comment
-
Hi! I've actually been working on something similar recently for our upcoming plugin marketplace (which is build on Vendure of course 😁) My import { DeepPartial } from '@vendure/common/lib/shared-types';
import { Address, VendureEntity } from '@vendure/core';
import { Column, Entity, OneToMany, OneToOne } from 'typeorm';
import { License } from './license.entity';
@Entity()
export class Organization extends VendureEntity {
constructor(input?: DeepPartial<Organization>) {
super(input);
}
@Column()
name: string;
@Column('simple-array')
invoiceEmailAddresses: string[];
@Column({ nullable: true })
contactEmailAddress: string;
@Column({ nullable: true })
taxId: string;
@OneToOne((type) => Address)
billingAddress: Address;
@OneToMany((type) => License, (license) => license.organization)
licenses: License[];
@Column({ unique: true })
username: string;
@Column()
password: string;
@Column({ nullable: true })
notes: string;
} and in my plugin's config.customFields.Customer.push({
name: 'organization',
type: 'relation',
label: [{ languageCode: LanguageCode.en, value: 'Organization' }],
entity: Organization,
ui: { component: 'organization-select' },
}); In my case, I've not defined the inverse relation of By the way, if you need more help on this, you are welcome to join our Discord community: https://vendure.io/community |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everybody, i'm evaluating if vendure can be suitable for my need which is a b2b ecommerce where a single company can sell products (spare parts to be more precise) to multiple companies, each one with their users, their pricing, their discounts, their address etc.
I need to group customers in organizations, and from the documentation i've got some hints about creating an "organization plugin" at the codegen page, but unfortunately there is no other code about it anywhere... therefore i'm trying creating it by myself.
I've used the CLI to create a new plugin and i'm creating the entity, i've add some custome fields like name, vat code, organization code but i'm stuck at relating it to the customers, i'm trying to do a OneToMany relation with the customer table and it require to add a field to the customer table, i've add a customField of type "relation" to the customer entity on the vendure-config file, but i'm unable to create the relation on the organization entity.
Can somebody help me?
I'm open to any kind of advice also about the best approach to create the organizations.
Beta Was this translation helpful? Give feedback.
All reactions