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.
3 years ago
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
3 years ago
Look at another plugin - example Nop.Plugin.Shipping.FixedByWeightByTotal
3 years ago
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
3 years ago
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
3 years ago
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.
3 years ago
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? )
3 years ago
other portal means nopcommerce already running code at client end
3 years ago
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.
3 years ago
thanks it was done
3 years ago
Sounds good :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.