The MVC, Packages, and File Paths

Permalink
Just finally getting feet wet with some package development and need to know how to do this:

I need to basically add code to the model of another package, but obviously I can't disturb the package, so is there a way that I can, within my package, override the model? (is this correct practice)

Ex. I know that I can upload a model/controller to the main folders in the root, which will override any existing model or controller file, but because I want to make a package, everything I make has to stay in the /packages/my_package_name/ folder, right? So how is this done?

WebSolutions
 
12345j replied on at Permalink Reply
12345j
Im not sure what you mean.
If this is for a client, then you should just edit the other packages model, you can disturb the package. (or are you worried about upgrades?)
If its for the mp, i doubt it will be accepted with this mod.
WebSolutions replied on at Permalink Reply
WebSolutions
Thanks for the reply! I don't want to disturb the other package because of upgrades.

My main goal isn't to develop it for the MP (so if it can't be done, I'll suffice for it to work for a client) but I would like it to be available in the MP after too.

How would I develop a package then that has to interact with another package's logic files (model/controller) rather than just the package's view?
12345j replied on at Permalink Reply
12345j
I could probably help more if you could give a specific example. If you don't want it in public just pm me.
WebSolutions replied on at Permalink Reply
WebSolutions
Definitely - I'm trying to make it possible that core commerce products have the normal price, but they also have several other price fields, each field belonging to a User Group - if a user is part of that group, they pay that price, if not, or if guest, they pay the normal price.

Right now, from what I can see, the price for the order is derived from the product model with the getProductPriceToPay() method. There are a couple of if statements here that determine the price, so I want to add another if in there so that it selects my User Group price, which I'm planning on setting up as a normal product attribute.
12345j replied on at Permalink Reply
12345j
Im pretty sure you can do this with 0 coding. If you take a look at discounts, you see the basic discount type, which you can only offer to certain groups or users.
WebSolutions replied on at Permalink Reply
WebSolutions
I wish that the discount was only a % off of every product no matter what, but I need it so that:

Product A    Product B
Default  100          100
Group A  90           50
Group B  80           60


So that each individual product would have its own price set, rather than just follow a % rule.

The discount would also still work as you have suggested if we only had a low number or products - we would just need to put the discount in for each product in the discounts section, but we have over 400 SKUs in this case, which would create a million individual discounts, making it too time consuming to enter in and difficult to manage afterwards.

We need the different prices for each group to show up on the actual product properties page so that they can be easily managed.

BUT... that being said, maybe I'm still missing something and you know of a good way to accomplish this without much programming! Otherwise, do you know how I would modify that price method?
12345j replied on at Permalink Reply
12345j
okay, i get it now.
2 options-
1) better option
create a discount type yourself. You'll need to have a table of all the groups and the discounts they et for each product, but that should be fairly simple to do. (unless its some bizzarre algorithm, in which case its even easier.
http://www.concrete5.org/marketplace/addons/ecommerce/documentation...
2) use the core_commerce_on_checkout_start event to calculate the prices. I did something like this for a project and it didn't end great (lots of spaghetti code), but it worked. you'd still need the table or algorithm for this one.