Is there a way to add a new search field in the Magento admin under "Orders"? I want to be able to search by coupon code usage (ex: search by coupon code: "sale2013", come up with all the orders that applied that coupon code during checkout).
I'm able to pull this data out of the Magento DB, but I'd really like to add this functionality to the Magento admin to make it easier for co-workers and my boss. Can it be done and, if so, ideas as to where I can start? Thanks guys.
The coupon code used during checkout is stored on the primary order table (sales_flat_order) when the customer checks out. If there is no value, then no coupon code was used. However, the data for the grid in the admin comes from the sales_flat_order_grid table; it comes from there instead of the primary order table for performance reasons which become particularly evident on very high traffic sites.
Now that we know where the data is that you need to filter on, and where the data for the grid comes from, we can move on to build it!
The first thing that you will need to do is add a coupon_code column to the sales_flat_order_grid table matching the definition of the column on the sales_flat_order table. The values in the coupon_code column of sales_flat_order should automatically populate into sales_flat_order_grid once the matching column is there and your cache storage has been flushed.
The data is updated on the order save, so to be specific, new orders and orders updated via the admin (even a comment on the order) will have the data populated. For existing orders, run a data upgrade script to copy the values over.
After the data/schemas are in place, you'll want to have the grid show a filterable column for it. For this you will want to rewrite the Mage_Adminhtml_Block_Sales_Order_Grid class from your custom module (please don't edit the core files directly, it will haunt you later) and override the _prepareColumns method with one that includes your column definition:
$this->addColumn('coupon_code', array(
'header' => Mage::helper('sales')->__('Coupon Code'),
'index' => 'coupon_code',
));
If you're very fresh on Magento development, I'd venture to say that I've only begun to help you. But you'll have plenty of reference points from which to dig in and build the functionality you need. HTH! :)
Adding new columns to a grid is easy with this extension:
https://github.com/magento-hackathon/GridControl
Add this extension, write your own with a gridcontrol.xml inside your etc directory
And then something like this should work:
<?xml version="1.0"?>
<gridcontrol>
<grids>
<order.grid>
<coupon_code>
<after>columnname</after>
<add>
<header>Coupon code</header>
<type>text</type>
<index>coupon_code</index>
<joinField>coupon_code|sales/order|coupon_code|entity_id=entity_id||left</joinField>
</add>
</coupon_code>
</order.grid>
</grids>
</gridcontrol>
Related
I wrote my own Magento function which calculates the percentage relation of orders to retours. In this way you can categorize customers into those, who never give bought things back (green - good customers), who sometimes make retours (yellow) and those ones, who return most of bought things (red - bad customers).
For this, I added a new db table which saves required information.
Now, I would like to add a new column in Magento's admin Customers->Manage customers which shows the appropriate color. I managed to add the header of the new column, but I have no clue how to show my custom calculations from my custom db table. Magento makes everything so complicated.
I edited the "app/code/core/Mage/Adminhtml/Block/Customer/Grid.php" and added the following code into the "prepareColumns":
$this->addColumn('abc', array(
'header' => "ABC"
));
So, how do I fill it with any data?
I appreciate any help.
The very simplest solution is to edit the prepareCollection function in the same class, and join your table to the results set. Then you simply have to set the correct index in your addColumn definition and the column should be populated.
Ideally of course you shouldn't be editing the core files, a slightly better option would be to instead rewrite the class, or you could go the whole hog and do it with events.
So do you maybe know how do to this? What do all the parameters exactly mean?:
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
Please give me any piece of advice. Let's say, I would just make a raw SQL query for each customer, make some calculations and put it out. I only need the customer's id to do this.
i'm building a website for a house builder and each house plot (k2 item) has a few extra fields associated with it such as 'price' and 'availability'.
i would like to display this extra field data elsewhere on the site perhaps in a table that lists 5-6 plots and displays their current price and availability.
the idea is to be able to change the price of a house in the extra fields section and then have this change reflected in other parts of the site that call on this extra field data.
i've read this article..
http://jurawa.com/notes/item/27-update-making-k2-more-like-a-true-cck-custom-admin-templates-and-calling-specific-extra-field-data
..which explains a process of displaying extra field data but i've not managed to get this to work. i also think that this method would only work if displaying extra field data while already inside the item that it relates to. i'm trying to display this extra field data around other parts of the site.
i'm trying to replicate something like the table that appears on this page (just above the map)
http://www.orionhomes.co.uk/development/brunswick-place
running the latest version of jooma and k2 and have full access to server and database.
hope someone can help..!
many thanks
I have used the Raxo All-In-One module to accomplish this in the past:
http://www.raxo.org/raxo-all-mode-k2.html
This, along with ability to insert a module in an article, would allow you to place the specific K2 content/fields wherever you need them and have them updated dynamically by K2.
Another option would be to create a new template for K2 and only output the extra fields in your item list. This would allow you to create the table view you are looking for.
There is a great plug-in for Joomla/K2 that does this for you at:
http://joomcar.net
It's called K2 Filter and Search Module and it will display a table with the extra fields as you have demonstrated in at:
http://www.orionhomes.co.uk/development/brunswick-place
You can definitely display those extra fields wherever you need them on the site.
This step-by-step tutorial may help you to create the extra fields.
Then you just need to enable the extra fields in your view and modify your template.
I am trying to create a ubercart module which automatically updates product listings. I thought that I just needed to edit these tables
uc_products
uc_product_classes
uc_product_features
The problem is no matter what I put in these tables, no products are listed in the Ubercart store.
What other tables do I need to update to do this? Or what steps do I need to take to get this module to add and/or update the products viewed in the web page? I would love it if someone could show me how to do it without resorting to SQL.
In Drupal 6, products are referenced to nodes. You might look at the feeds or node import module for automated product listing updates/creation.
It seems there are a lot more tables to alter before it will show in the Ubercart store. However I don't think you need uc_product_features.
These tables are
node
node_type
node_revisions
uc_products
uc_product_classes
They must belong to a class defined in uc_product_classes and node_type.
node_revisions is what is displayed in the store front and node.staus must be set to 1. It is the publish variable.
Also
node.nid must equal mode_revision.nid
and
node_revsion.vid must equal mode.vid
otherwise in the store front listing for that item will be
"n/a"
And while it didn't tell me all I needed, I found the following site to be informative.
http://tiger-fish.com/blog/drupal-6-turning-existing-node-type-ubercart-product
I'm wondering if anyone has found or written an extension that would allow a magento website administrator the ability to add values to their products attribute while adding the product. For example, if I sell books and want the book author to be in a drop down list so that it would be used in layered navigation, it seems odd that I would have to add the author via the attributes section before adding the product. From a workflow standpoint it really makes sense to have an "add new value" button next to the drop down on my add product screen.
Anyone have any thoughts or insight?
It's a piece of cake to do, if you know jquery and the (if I may guess) extremely simple model behind magento.
As the other guy said, throw some money and I'll do it ;)
Otherwise, real easy -> find where that dropdown is generated, add a button next to it that opens a popup which you fill "create a new thingie" stuff, create button -> +create +close +refresh your dropdown.
Definitely easy.
And considering the attribute dialog already exists in the tool you cold probably take most from there and just add the popup handlers / button / +refresh .
This extension can Import/Export products and customers from/to CSV file. Create categories, add attribute options, import images and media galleries, reindex, refresh cache, media and price rules automatically. In addition you can backup the entire database in SQL format.
So from above, once you make the csv file, you just have to add the Author header and it would build the list from there. However, the attribute must exist first. I am using this method for the creation of my own manufacturer attribute options.
AMartinez_CustomImportExport
Can't say I have, but I've developed something similar that creates an attribute and adds it to multiple products, it's completely possible, you just need to add something that will call the add attribute on the add product page or change the new product flow to allow a new attribute and add it if needed.
Don't let them scare you, it's not as hard as some people might describe :)
My curiosity finally took over my laziness and I managed to create the module author requested. It's available on github.
Please feel free to check it out and update it if you wish. Maybe in some near future I'll post it on Magento Connect, if feedback is good.
Here's some code that checks if an attribute value exists and adds it if it doesn't: http://www.magentocommerce.com/boards/viewthread/26234/
Shouldn't be too hard to integrate it with the "Add product" form.
I'm building a Magento shop for a customer and would like to add an attribute to all products that functions as a dropdown list. Like the 'Manufacturer' attribute.
However, instead of manually entering the list of values for the attribute I'd like the values to be populated from an external site. So, every time you create a new product or edit an existing one, the dropdown is populated with the up-to-date list of values that has been retrieved from a remote site. The list should not be fetched just once during creation of the attribute, but every time a product is created or edited.
For example, assume you can get a list of all Manufacturers via curl from a remote site. The names in this list are occasionally modified or added, however the id's stay the same so they should be used behind the scenes. How would you prefill the values of the manufacturer's dropdown?
I know how to create a basic custom extension, but extending the adminhtml backend is new stuff for me.
Any help is appreciated.
Magento product attributes are extremely flexible, but having dynamic values per product would mean you would need one attribute per product which doesn't make much sense so I am assuming that these attribute values share some things in common among products in your store so you will have a limited number of attributes (or one?). For each such attribute you should create the attribute and the backend model for it beforehand and then use a cron job or event update the attribute value options from your API and cache them locally in the database or some other method. You can add an attribute in your module installer like this:
$installer->addAttribute('catalog_product', 'my_attr_code', array(
'label' => 'Attribute Name',
'required' => false,
'input' => 'select',
'source' => 'namespace/source',
'default' => 'none',
'position' => 1,
'sort_order' => 3,
));
Or roll your own SQL insert statement for the eav_attribute table. Make sure to assign your new attribute to an attribute set in the backend so that it is usable with your products. Then you create a model at My_Namespace_Model_Source which extends Mage_Eav_Model_Entity_Attribute_Source_Table (assuming you want a select input for your attribute values) and implements at minimum the following methods:
getAllOptions()
getOptionText($value)
So these would pull from the dynamic options that are cached locally and for the most part your new attribute will behave like any other in Magento. Be sure to use intelligent caching because these methods could potentially get hit many times in one page load. There may be an event you could observe that is called right before a product create or edit page is displayed, otherwise just override a class or controller or use a Magento cron task.
Edit: You could also use the existing Magento attribute models and create your option values through the existing API but I assume that to perform syncing or for some other reason you may need some additional metadata in which case you will want to have a custom backend model.
Not a good answer i guess but here goes, I would first add an attribute and then reverse engineer it to see how it is populated.
Then in the product display page on the admin, I would override the productController's edit and new actions, to load the values using curl for that attribute(you can lookup the id of the attribute in the eav_attribute table)
You can then package this as a custom extension, so you dont edit core code directly. Good luck!
You need to look up Magento Event Dispatchers.
Basically, every time an event occurs - updating a product, submitting an order, deleting something etc - a message is sent through the system. These messages can be caught and can then trigger methods you have created. To achieve what you want, you would need to catch the event that is triggered when a product is created and updated and get this to run a method from one of your custom modules. This method would then grab the value from the remote site and update the product with it.
After a quick Google Search, I found the following article:
http://blog.baobaz.com/en/tag/magento-events
You can find what Magento events are triggered by looking at the appropriate module code.