lightspeedretail / webstore

Web Store eCommerce solution for Lightspeed
http://www.lightspeedpos.com/webstore
Open Software License 3.0
85 stars 63 forks source link

Unable to extend or overwrite an extension model #615

Closed echantigny closed 10 years ago

echantigny commented 10 years ago

I want to extend (or overwrite in the custom folder) a model contained in the extensions, more precisely, the Order Lookup form in the sidebar. All I need to do is to add the yii::t() function that the strings because they are missing. I like to avoid making changes to core files but I can't seem to find a way to extend it or to fully copy the model file in the Custom folder, like we currently have to do with the normal model files.

brandinchiu commented 10 years ago

If you need to modify an aspect of an extension, you need to copy the ENTIRE extension to /custom/extensions and then make whichever changes you want to it. Then, in your view files, when you call the extension, call the one you changed in /custom/extensions instead.

echantigny commented 10 years ago

Since the extension is part of the core system, the order lookup form, I don't feel like this is a really good idea though. That is what I did to make it work, but it doesn't feel right to leave it like that for future updates.

brandinchiu commented 10 years ago

Its not the same thing as editing a core file, simply because the file you are editing is within the /custom/extensions folder. This is essentially the same thing as editing view files as part of a theme. its a copied file from /protected/views-cities and editing under /themes/mytheme/views/myview.php. if you were applying changes to the ACTUAL file in the /protected folder, then yes, this would be a problem. Not as much given the above method.

echantigny commented 10 years ago

Ok so here's my try at changing the Order Lookup Form, which of course, doesn't work.

Copied the whole extension from core/protected/extensions/wsborderlookup to custom/extensions/wsborderlookup.

In my template, changed <?php $this->widget("application.extensions.wsborderlookup.wsborderlookup",array()); ?> to <?php $this->widget("custom.extensions.wsborderlookup.Wsborderlookup",array()); ?>

Tried to change and/or add custom.extensions.wsborderlookup.Wsborderlookup to the main.php file with same result.

The alias « custom.extensions.wsborderlookup.Wsborderlookup » is invalid.

brandinchiu commented 10 years ago

Can you dump your include path? It should be in /config/main.php under import.

echantigny commented 10 years ago

As I said, tried adding, modifying... same result

// autoloading model and component classes 'import'=>array( 'application.models.', 'application.models.base.', 'application.models.forms.', 'application.components.', 'application.components.wscontrollers.', 'application.helpers.', /'application.extensions.wsborderlookup.Wsborderlookup',/ 'application.extensions.wsshipping.WsShipping', 'application.extensions.wspayment.WsPayment', 'application.extensions.MissingMessages.MissingMessages', 'application.extensions.s3.', 'custom.extensions.', 'custom.extensions.wsborderlookup.Wsborderlookup', 'custom.helpers.', 'custom.models.', 'custom.xml.', 'editable.' //easy include of editable classes ),

brandinchiu commented 10 years ago

I can't tell if the * is missing because of github. I'm assuming all of your includes end in .*

EDIT: Oh, your call to the extension:

<?php $this->widget("custom.extensions.wsborderlookup.Wsborderlookup",array()); ?>

Unless you actually went in and changed the file name as well as its contents, you have a capital in the latter call that shouldn't be there. Both "wsborderlookup" should be lower-case.

echantigny commented 10 years ago

Oh wow!!! Thanks so much. It was actually the issue, the capital in Wsborderlookup. Not sure why they are cased differently in the main.php and in the page call, but at least, now it works. Thanks a lot for this one.

Yeah, all the end after . contained stars. Might have something to do with Markdown pulling them out for some reason.

For anyone who is reading, just in case, I also needed to change this in the init() function of the extension Yii::import('custom.extensions.'.get_class($this).'.models.*');

brandinchiu commented 10 years ago

Glad to hear it's working :D On May 26, 2014 1:44 PM, "echantigny" notifications@github.com wrote:

Oh wow!!! Thanks so much. It was actually the issue, the capital in Wsborderlookup. Not sure why they are cased differently in the main.php and in the page call, but at least, now it works. Thanks a lot for this one.

Yeah, all the end after . contained stars. Might have something to do with Markdown pulling them out for some reason.

For anyone who is reading, just in case, I also needed to change this in the init() function of the extension Yii::import('custom.extensions.'.get_class($this).'.models.*');

— Reply to this email directly or view it on GitHubhttps://github.com/lightspeedretail/webstore/issues/615#issuecomment-44207085 .