Reputation: 31
I am originally a php developer so this may sound a little bit like a newbie question. I just got on to spree which is so far amazing for the configuration easiness.
I wanted to go a bit further to see if I could recreate a functionality provided by instacart which I thought was concrete and a good test to see how far I could go with spree --> shop from different stores.
The way I was thinking to do that is by simply adding a new model (?) "shops" which would be linked to products. "Shops" contain an id, a name, an address and a logo picture.
Everytime a product is added in the admin, a shop has to be selected for this product.
What I have done so far is - created the extension "shops" - an empty controller in it - a couple of views
I am a bit stuck on the model part - where / how should I create the shop model and integrate it to products. Could anyone give me s a little help?
Thanks a lot!
Joseph.
Upvotes: 1
Views: 1065
Reputation: 1165
Sounds like you're trying to reinvent the wheel, take a look at https://github.com/spree/spree-multi-domain
To answer your actual question, I'm going to use code examples from that extension.
New Model: https://github.com/spree/spree-multi-domain/blob/master/app/models/spree/store.rb
Code that makes products belong to that model: https://github.com/spree/spree-multi-domain/blob/master/app/models/spree/product_decorator.rb#L2-L3
You'll need the necessary migrations to get the columns/tables there, but it shouldn't be much more complex than that.
Upvotes: 1