How to create a new table in plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 3 años
i have an issue i have created a new plugin for that i need to create 2 tables on plugin install i am newbee in this please help
Hace 3 años
Look at another plugin - example Nop.Plugin.Shipping.FixedByWeightByTotal
Hace 3 años
ok but i need to insert values in this table whenever new product added so i have confusion that when i install plugin to other portal then how it will insert entries into this table because product page is different and plugin is different
Hace 3 años
Once your plugin creates the table then of course there needs to be some other code to write the values to the table.
As New York says best look at other similar plugin to see how it works
If it is extending the Product Table did you look at using Product Attributes ?
Otherwise you will need to look at how to create new razor pages and how to override existing methods
Hace 3 años
shinestar1987 wrote:
ok but i need to insert values in this table whenever new product added


On this particular note..

You can use event handlers. you can get event like EntityInserted...and get data from that.

for how to use...as New york said..you can check other default plugins....

For more information
https://docs.nopcommerce.com/en/developer/tutorials/events.html

list of events....
https://www.nopcommerce.com/en/boards/topic/37824/list-of-all-events-for-event-handlers

Thank you.
Hace 3 años
shinestar1987 wrote:
ok but i need to insert values in this table whenever new product added so i have confusion that when i install plugin to other portal then how it will insert entries into this table because product page is different and plugin is different


"other portal"??  Please clarify what your trying to do.  (Is there an external system involved?  Which system is inserting records into custom table?  Which system needs to read those records, and when? )
Hace 3 años
other portal means nopcommerce already running code at client end
Hace 3 años
shinestar1987, what are you trying to achieve here? This is really confusing.

If you want to create table for a plugin then follow other plugin (Nop.Plugin.Pickup.PickupInStore)

If you want to insert/update/delete data when you are doing same thing for Product then implement EntityInsertedEvent for product.

If you want to extent existing product table then you can use GenericAttribute table.
Hace 3 años
thanks it was done
Hace 3 años
Sounds good :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.