Search This Blog

Monday, April 30, 2012

Magento admin grid add from and to search in admin grid

Magento admin grid add from and to search in admin grid

$this->addColumn("designer_id", array(
                "header" => Mage::helper("Module")->__("User ID"),
                "align" =>"right",
                "width" => "50px",
                'type'  => 'currency',
                "index" => "user_id",
                ));

                'type'  => 'currency', is used to search for integer or decimal type

$this->addColumn("created_date", array(
                "header" => Mage::helper("Module")->__("Modified Date"),
                "align" =>"center",
                "width" => "100px",
                'type' => 'datetime',
                "index" => "mod_date",
                ));

                'type' => 'datetime', is ued to seach date time range

Thursday, April 26, 2012

Magento admin grid mass delete, mass status change checkbox option

Magento admin grid mass delete, mass status change checkbox option

In your Grid.php add
protected function _prepareMassaction()
    {
        $this->setMassactionIdField('Module_id');
        $this->getMassactionBlock()->setFormFieldName('banners');

        $this->getMassactionBlock()->addItem('delete', array(
             'label'    => Mage::helper('Module')->__('Delete'),
             'url'      => $this->getUrl('*/*/massDelete'),
             'confirm'  => Mage::helper('Module')->__('Are you sure?')
        ));

        $statuses = Mage::getSingleton('Module/status')->getOptionArray();

        array_unshift($statuses, array('label'=>'', 'value'=>''));
        $this->getMassactionBlock()->addItem('status', array(
             'label'=> Mage::helper('Module')->__('Change status'),
             'url'  => $this->getUrl('*/*/massStatus', array('_current'=>true)),
             'additional' => array(
                    'visibility' => array(
                         'name' => 'status',
                         'type' => 'select',
                         'class' => 'required-entry',
                         'label' => Mage::helper('Module')->__('Status'),
                         'values' => $statuses
                     )
             )
        ));
        return $this;
    }
-----------------------------------------------------------
in your adminhtml-> XXXcontroller .php file
 public function massDeleteAction() {
        $ids = $this->getRequest()->getParam('Module');
        if(!is_array($ids)) {
            Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select Banner(s)'));
        } else {
            try {
                foreach ($ids as $id) {
                    $banners = Mage::getModel('Module/Module')->load($id);
                    $banners->delete();
                }
                Mage::getSingleton('adminhtml/session')->addSuccess(
                    Mage::helper('adminhtml')->__(
                        'Total of %d record(s) were successfully deleted', count($ids)
                    )
                );
            } catch (Exception $e) {
                Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
            }
        }
        $this->_redirect('*/*/index');
    }
   
    public function massStatusAction()
    {
        $bannersIds = $this->getRequest()->getParam('module');
        if(!is_array($ids)) {
            Mage::getSingleton('adminhtml/session')->addError($this->__('Please select Banner(s)'));
        } else {
            try {
                foreach ($ids as $id) {
                    $banners = Mage::getSingleton('Module/Module')
                        ->load($id)
                        ->setStatus($this->getRequest()->getParam('status'))
                        ->setIsMassupdate(true)
                        ->save();
                }
                $this->_getSession()->addSuccess(
                    $this->__('Total of %d record(s) were successfully updated', count($ids))
                );
            } catch (Exception $e) {
                $this->_getSession()->addError($e->getMessage());
            }
        }
        $this->_redirect('*/*/index');
    }

Magento in admin html backend add a coloumn Action

Magento in admin html backend add a coloumn Action

magento add action coloumn in admin  grid

Code

$this->addColumn('action',
                        array(
                            'header'    =>  Mage::helper('Module')->__('Action'),
                            'width'     => '100',
                            'type'      => 'action',
                            'getter'    => 'getId',
                            'actions'   => array(
                                array(
                                    'caption'   => Mage::helper('Module')->__('Edit'),
                                    'url'       => array('base'=> '*/*/edit'),
                                    'field'     => 'id'
                                )
                            ),
                            'filter'    => false,
                            'sortable'  => false,
                            'index'     => 'stores',
                            'is_system' => true,
                    ));

Thursday, April 5, 2012

Magento Service Temporarily Unavailable The server is temporarily unable to service your request

Service Temporarily Unavailable The server is temporarily unable to service your request …..

There are two main reasons why you may get this error.

1. There is an actual problem with the server, resulting in the 503 error response. In this case, you should contact your hosting provider.

2. Your store has been put in maintenance mode. If Magento sees a file named maintenance.flag in the root directory, it will automatically redirect all requests to the default 503 error page. This can be used during upgrades, etc. to prevent users from accessing the store. The solution is, as already mentioned, to delete/rename the maintenance.flag file.

There might also be a good idea to create a more user friendly “maintenance page” than the 503 error, which is kind of misleading for customers.

Deleted file and removed cache.. and its working fine..

Magento use Tire Pricing or set rules for discuonts

Q
Tier Pricing for discunts

Answer
Hi,

Tier Pricing is a promotional tool provided by standard Magetno
It allows a store owner to price items differently for higher quantities.

1. In the Magento Admin Panel, navigate to Catalog > Manage Products.
2. Find the product that you want to add tier pricing to (or create a new product) and click Edit in the Action column.
3. Click on prices tab on the left
4. Click “add tier”

You will get tier tab with “web site”, “customer group”, “quantity”, “price”.
Make your choise. In price field you put price which makes 50% of your product cost. and this product will be sold with this discount provided that buyer puts in cart .....(make your choise in quantity tab) items.
More over you can stipulate the group of customers who are provided with the discount. For example - only registered customers.

If you want to spread and apply discount coupon you can have a look at GoMage LightCheckout for Magento it is one page checkout extension which is amoust bunch of useful extensions in one. By the way it is compatible with 1.5 Magento vesion.

Monday, April 2, 2012

magento custom form fields

In this tutorial, we are going to see all the different form fields we can use in admin forms.

Magento has many different type of field available by default, so lets see the syntax of using each of these fields. This tutorial is in continuation of the previous tutorial so the same classes will be used as in the previous post.
All the code’s written below are written in the class Excellence_Form_Block_Adminhtml_Form_Edit_Tab_Form inside the _prepareForm() function as shown in previous tutorial. All the different type of form fields available in magento are located in folder lib\Varien\Data\Form\Element

http://www.excellencemagentoblog.com/magento-admin-form-field