How to edit/create/delete relations / references [react-admin] - react-admin

Given the demo category edit page as a reference
https://marmelab.com/react-admin-demo/#/categories/0
Is there a built-in way/guidelines to add/remove products from the category? i can't find any reference about in in the docs/example

No man, you should do it by yourself according your needs.
You can only create separate list with actions as shown in tutorial and edit it outside of category itself, as standalone table.
If u want to edit list of products which only belongs to concrete category, you should create your own component.
You may be need something like that example: https://codesandbox.io/s/rm4jy6n68o

Related

What is the best relational schema (or ERD) of dynamically nested objects?

I am trying to draw the table diagram of a product listing web application.
Application logic:
Admin user will create:
Categories (must be dynamically created by admin user),
Category's attributes (must be dynamically created by admin user),
Selection of Category attribute's options (must be dynamically created by admin user)
User will post a product under a specific category and must choose category attribute's option for each category attributes to successfully save the product.
Example: Admin creates category "food"
"food" has its attribute "meal_type" and "sugar".
"meal_type" has its options "breakfast", "lunch" and "dinner".
"sugar" has its options "with-sugar" and "non-sugar".
and now user can post his product "pizza" under category "food".
When user chosen "food" category, he must see its attributes "meal_type" and "suger"
and then must set those option values.
For example, "pizza"'s category is "food" and "meal_type"="breakfast", "sugar"="with-sugar".
And I want to call these option values together with product details when selecting these items.
I have made this (removed non-related fields)
but I am not sure this will work and be efficient at same time.
What is the most efficient relational schema (or ERD) for case like this?
I could help, but I don't really understand what exactly a user is supposed to do? Is he supposed to order products on the website? If so, maybe the naming of the tables should be different, eg "order_product" instead of "product"?
and as for the performance, at this stage and with this structure there should be no problems.

How is a category's `tree_id` determined in BigCommerce?

I observe that all categories have a tree_id of 1 when getting categories using the BigCommerce API. I was expecting that each top level categories and their children will have a different tree_id. How exactly is this category attribute being determined by BigCommerce? Thank you!
A store can have multiple, independent category trees which are useful when using multi-storefront. This allows you to have a distinct category navigation on different storefront websites.
https://developer.bigcommerce.com/api-reference/448cda022db6a-get-all-category-trees
By default, when using single-storefront, all categories are assigned to the first, default tree which exists when the store is created. It has an ID of 1.

How to set customer specific pricelists which is common in B2B

How to set customer specific pricelists which is common in B2B.
Pricelists per customer or organisation.
If this not exist out of the box, should i tag pricelists witch dynamic properties or add a custom condition, what is tag (TagsContainsCondition).
It dosnt seems to be possible to add own conditions for pricelist assignments!?
I guess this is the best method to override if you dont want to send to many pricelists to the client:
PricingServiceImpl.EvaluatePriceLists
This is already possible out of the box. Simply go to price list assignments and then add a new condition: "Tags contains". In the frontend, you'll need to populate the tags passed to the pricing engine with whatever values you'd like, for instance it can be customerid, or organization name.
You can also extend and add your own conditions as described here: http://docs.virtocommerce.com/display/vc2devguide/Composing+dynamic+conditions.

SAP Business One I Query inventory base on user defined field

I am running a query on a product. I need a field that will look at the user defined field which contains another product and check that stock level. Any help would be great.
What is the main objective?
Are you trying to check on that item because that item is the material/component? or act like a substitution?
Using UDF is quite not feasible as you have to get the link to the Item Master Data, and I have not figured out yet how to do that.
But if you are using it as substitution, why don't you use Alternative Item in Inventory > Item Management > Alternative Items? It will show on Sales Quotation for you to display it to customer. Or during Sales Order, you can get it displayed for alternative should your main item is shortage.
If you are using those item as a component, I suggest you use Bill of Material. During Production Order you will be able to see those component's availability in qty, and also you can have more than one, unlike UDF.
Hope this helps.
I think the key part you're missing here is the naming convention which SAP adpots for user defined fields.
Correct me if I'm wrong, but it seems that you're capable of querying these fields from a SQL point of view.
UDFs by defuault, will have their column name prefixed with "U_".
For example, the UDF 'AnotherProduct' will be referred to in SQL as 'U_AnotherProduct'.
Hope this helps, if not, please explain your problem in some more detail.

NHibernate update reference

Entities
We have an entity called Product which is loaded using NHibernate.
Product has a category which NHibernate happily populates for me.
Database
In the database, Product has a foreign key for category.
Scenario
User edits this Product (via a web interface) and chooses a different category (say instead of "Fish" we select "Veg").
This is probably a dropdown list, with each category shown. When they choose a different category we get an int key.
Problem
Obviously we now want to save the changes to Product but in effect the only change is to save a new int (say 2, instead of 1).
So we retrieve the existing Product, and now comes the problem.
We don't have a "CategoryID" field on Product, we only have a Category property.
But we don't really want to retrieve the category (by id) just to assign it to the Product.
So I guess what I want to know is should we...
a) Add a CategoryID property to Product
b) Create a new category, assign it the relevant id and attach that to Product (but surely that will cause errors, or overwrite the existing category)
c) Retrieve (lookup) the category from the system (by id) and attach that to the Product
d) Do something else entirely!
It looks like you might be able to using the Session.Load(id) functionality.
Session.Load is a special method that returns a proxy with the ID until you request another property at which point it loads. It throws an error if there is no item matching the ID. Try something like:
product.Category = Session.Load<Category>(2); //2 being the new category ID
Session.SaveOrUpdate(product);
I just did a little testing and it did not seem to pull back the entire Category.
Updated: Session.Load is the correct answer
product.Category = session.Load<Category>(2);
session.Save(product);
Use NH's EnumStringType<T> to map your Category as an enum to the respective database value (which can be a string or a number). You'll find quite a few usage examples, if you google for it.
HTH!