Magento product page adjustments - php

I need to display on product page few fields from corresponding row of MANUFACTURERS table
I don't know how to find required Model and Controller for that task.
Manufacturers table is the table where manufacturers stored
And there is another one table Manufacturers_products (manufacturer_id, product_id)
What I did is added 2 checkboxes to backend add/edit manufacturers form and added to fields for this checkboxes in manufacturers table.
Now I need to display 2 types of strings for each of fields, depending on user choice, during process of manufacturers create.
For example, if 1st checkbox is checked, then on all products, that have the same manufacturer, text row must appear, telling that 1st checkbox is checked. The same for the second.
Actually I need this checkboxes take part in product compare and filtering.
Any information will help. Thanks.

Here is my solution.
1) Added new block to Manufacturers module layout ( manufacturers.xml), situated in the layout folder of frontend site theme
2) Created new block class in Manufacturers module Block folder and specified it in the type attribute of my block, added on the 1st step
3) In the block class, you must extend protected method
_tohtml()
by adding your own behavior. Don't forget to call
parent::_tohtml()
4) To work with Manufacturers table, you must add new method to Manufacturers model of this module and make here a call to
$this->getRequest()->yourNewMethodName()
5) Add new method with the same name to the Manufacturers model, placed in Mysql4 folder or Model folder in this module. Here you must add your query, that will retrieve data from manufacturers table
You can also create enable/disable config parameter. To do this, you must read about Magento system.xml configuration (Tabs,Sections,Groups,Fields)
This solution steps are acceptable for any magento module. Hope this helps to somebody.

If you want to get the Model and controller of the extension then you need to check the Module files. In order to check that just
a) Go to app/code/community or app/code/local there you will find the Package name like FME and inside that folder you will find your module name.
b) In order to check the Model just Go inside the Module folder->etc folder and check the config.xml
c) In config.xml you will find a code like
<entities>
<modelname>
<table>tablename</table>
</modelname>
</entities>
In the above code Modelname tag will give the modelname
d) In order to find the controller you need to check the controllers folder.
hope this helps!!

Related

Magento - How to create an Adminhtml page with grid table getting data from custom MySQL table

I'm using Magento 1.9.0.1.
Right now i'm working on a custom extension for Magento and i need to know how to get the data from a custom MySQL table into a table in custom admin panel page.
I've already added a custom page in the admin panel, here it is:
Here is the code of this page /app/design/adminhtml/default/default/template/vivasindustries/smsnotification/about.phtml:
<h2> Hi there</h2>
This is new custom page where i must add a grid table!
In this page i want to add a grid table like this one:
This is just an example of what kind of table i need.
In this table there must be in first time so i can understand how the things work only 3 cells - Receiver,Phone and Date which is fetching data from my custom MySQL table VivasIndustries_SmsNotification.
Here is a picture from the phpMyAdmin so you can see the structure of the table VivasIndustries_SmsNotification:
So at final i want to say that i want this data to be snown in my custom admin page a grid table..
Please help me out to make this thing.
Thanks in advance!
I would recommend that you look at an existing block class, such as the Catalog -> Manage Products one:
Mage_Adminhtml_Block_Catalog_Product_Grid
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php
You can copy that file to your own module, and rename the class to [Namespace]_[Module]Block[BlockName]
You'll probably want to change the code in the _prepareCollection and _prepareColumns methods.
As well as creating your own model inside your module to retrieve the data from the database, you might want to look at keeping the getCollection() method by inheriting certain classes, not sure which class you would need to inherit though.

Clone/duplicate internal modules in the admin (sales, orders...) in opencart

i need to clone the "orders" module which is available under sales->orders. I have made a copy of the sales/order.php under the controller, model and languages to sales/your_orders.php and changed the class names and language files to the relevant name.
But i cant see Your Orders below the sales menu in the administration.
Can someone please let me know how can i get it working?
Now You have to edit also the controller, language file and template for header
admin/controller/common/header.php
admin/language/<YOUR_LANGUAGE>/common/header.php
admin/view/template/common/header.tpl
and add (copy and edit) lines for that new menu entry...
Duplicate and edit text, var
//files
admin/controller/common/header.php
admin/language/english/common/header.php
admin/view/template/common/header.tpl
Duplicate & edit database table
Set Permission
Or using
vqmod

Adding a search field to the Magento admin

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>

How to add a new view (and also a new Menu Item Type) to existing joomla 2.5 components?

Maybe I want to add a new view, and also a new Menu Item Type to content component.
What are the steps please?
UPDATE
Question (by #ValentinDespa) :
You want to extend com_content functionality or you want to override a
view or to build a new component that does something?
As I said, I want to extend com_content and add a new view to it. There are some views like Single Article, Category Blog, and Category List right now.
I want to add another menu items called Article Titles, so titles only will be displayed but with some parameters (like columns count).
It is a need that is not supplied by current features.
NOTE
Guys, it doesn't matter what my new view should be like, please tell me How to create a new view.
Yes You can create a new view.
Its simple just copy any of the view (category,blog) from your com_content.
The file structure should be like inside the folder.
Step 1
view.html.php
tmpl
your layout names(default.php)
xml file.
Also remember to change the class name of the view.html.php
Step 2
Add a controller file (just make a copy of existing one category or blog)
Controller name must be your new view folder name.
Also remember to change the class name of the controller
step 3
add a model file for your new view (same make copy of any existing)
remember to change the class name and file name should be view folder name.
Then you can access this view by giving correct url.
eg: www.example.com/index.php?option=com_content&view=yourviewname&layout=yourlayoutnames.
Here I mentioned view folder name must be controller and model file name we can achieve with other name also but it will create problem for you when you are not good in joomla.
Note:
For adding a view you don't need to install a component its not a good idea at all.
Also You can add multiple layouts in a view
inside your tmpl folder just create new files.Also don't miss the controller and model to put in com_contents/controller and com_contents/model folder
for More help take a look at this

magento custom form on product page

I'm new to Magento, and i need some conceptual guide and/or references.
I need to create custom form that will be a part of product-info page (at it's bottom) and that will collect user input (email, size, color). Only some product will have this feature/form (it's up to admin). So, goal of this form will be to email store-admin about a product that is available in stock but not in wished size and/or color. Should i customize existing Contact us form or should i create fresh custom form in new module?
Form should submit data to admin via email along with name of the product.
Ok, so first create a .phtml file under app/design/frontend/[namespace]/[theme]/template/catalog/product/send_request.phtml
then, add this .phtml file reference in catalog.xml in /app/design/frontend/[namespace]/[theme]/layout/catalog.xml
<block type="core/template" name="customer_request" template="catalog/product/send_request.phtml"/>
below the :
<label>Catalog Product View (Any)</label>
section but you should find to right section where to place ( you will find after a few try )
Finally, add your php logic into send_request.phtml file. The form contain that you implemented in send_request.phtml will available under product view page.
Sounds like you'll need a custom form. You'll need a new database table to store the data, a Model to represent the data, and a controller to post the form to at the very least. You'll probably want to add an attribute to Products which is a yes/no of whether to display the form. You'll also probably want to view the data, so you'll have to make pages in the admin site. Perhaps a grid of all answers and a page to view/edit a specific answer.
There is a free extension available. You can use this extension and customize it according to your needs. Product Questions

Categories