I have searched almost all question but didn't get any hint how can i add coupon code from module...?
I have created module and from front side that is 'catalog\controller\module\mycoupon' i want to add coupon code auto on database, for adding i use this code
$this->model_sale_coupon->addCoupon($this->request->post);
but for that i need to load model 'sale/coupon' but which is located in admin controller so how can i call that model into catalog module ?
Or do i need to add that via DB model directly on database?
$this->db->query();
I am getting this error "Notice: Error: Could not load model checkout/cart!" because its outside catalog right how to call that?
My aim is to create coupon code directly on fly when someone click on submit.
Copy the addCoupon method from admin/model/sale/coupon into catalog/model/checkout/cart and then you will be able to call the method from the front side. You may need to adjust the method.
If you don't wish to modify core files, simply create a new model and load that so that your changes won't be overwritten on upgrade.
Related
I am having some struggles how does exactly django.admin.LogEntry objects are created.
Consider the following scenario:
I have a bunch of functions which take a csv file with data that allow me to create multiple objects at one call (just iterate through the file, use the data and if data in given row is correct: create a Model instance). I want to make sure that that each of that creation will be logged.
The question is: django docs are not very descriptive on how does LogEntry works and I am not sure if such actions (not taken in the admin panel itself) will be logged there. Also: will the LogEntries be created for the related objects or I have to trigger them manually?
Does anybody got any experience with such scenarios and can share thoughts about it?
The LogEntry model is in the Admin package and only used by Django admin by default. It is used in the admin layer and not model layer when saving objects. if you want to use it outside the admin, then you will have to manually create the entries yourself. That also means the admin will likely display entries of changes made by normal users so you have to think about how you want the entries displayed
We are using LogEntry/django_admin_log and recording additions, changes and deletions made from Django Admin. However we have two issues we need to address:
1.) Changes record only the field that changed. Not the old and new values. We would like to add the specific details of all changes.
2.) We would like to record an action in this log every time a page is viewed on the Django Admin panel.
How would it be best to proceed?
We are happy to do some work to extend the existing functionality of this, or we are happy to move to a completely new 3rd part module if necessary, or write our own. But would like some guidance from some experts?
We had similar requirements in terms of keeping history and track of actions done by users with a higher level of detail in terms of values changes. What we ended up doing was creating a new model called "History" which we populated with the user, the name of the model being changed, the instance id and a dictionary called changes showing the name of each field changed and values from - to.
In order to populate the new model, we overrode the save_model function in the admin file for the model we want to track. Regarding the page views, you can overrride the get_fields if "obj" is not None and create an instance of History accordingly.
Do you know what file to edit when you want to save order details in database after purchasing product in virtuemart 2?
I want to save some order details into another table after purchasing. But I don't know what file to modify, I found the controller as well as view files for the cart but can't find the model where the data are inserted to database. We are currently using Joomla 2.5.17 and Virtuemart 2.0.26,
In VM 2.x you can find the related controller as cart.php have a function confirm().
It calls a function from cart helper file. confirmDone() you can add your custom function inside any of these function or directly in order.php model file on admin side.
These function accessing time you will get cart session so all the cart items data will be available inside these functions.
Hope its helps..
I'm working on an Ember.js application that contains several models with dependencies. For example, when setting up a model for Client I include the attribute portfolios : DS.hasMany('Portfolio')
When a user enters the app, they are presented an option to immediately add a new portfolio at the route portfolio.add where among other form fields they are presented a drop down to select the client for whom they are creating the portfolio, as well as an option to create a new client via {{#link-to client.add}}. This is NOT the only way a user could get to the route client.add
I'd like for Ember to remember that the user got to the client.add route via portfolio.add, change the text of the submit button to indicate that they will return to portfolio.add after saving, and to transition back to portfolio.add after the promise returns successfully where it will auto select the newly created client in the drop down.
So far I've thought I'd use this answer: How can I get My previous route? to check the previous route, and possibly create a similar mixin for storing a reference to the created client record.
It's a hack, and I'd rather pass related objects/properties directly. Is there a better way?
I ended up advancing my Ember build to Canary and including Ember.FEATURES["query-params"] = true;
I then added a routedFrom parameter when shifting into a view that would need to route back on completion and in the original route's model I added this.transitionTo('originalroute',{routedFrom:null}); to clear the routedFrom parameter.
Im using the following statement to set Language Option in my projects which works as expected.
request.session['django_language'] = "de"
This is fine with in View, but when the control goes to other files to connect to DB or external services how can I access it. I dont want to pass the request object through out all the application.
If something like UserContext/RequestContext where every request has to go-through it (Middleware) so that I can set it there and access it without help if request object.
I understand from the headline that you want to store the language per user.
It might be best to extend the user model and add a model field for preferred_language.