Thursday 31 July 2014

override adminhtml block magento

Go to custom module config.xml

this will overrite Mage/adminhtml/block/customer/group/edit/form.php
<config>
     <global>
              <blocks>
            <adminhtml>
                <rewrite><customer_group_edit_form>Bill_Checked_Block_Adminhtml_Customer_Group_Edit_Form</customer_group_edit_form>
                </rewrite>
            </adminhtml>
        </blocks>
     </global>
</config>





then create file in   app\code\local\Package\Module\Block\Adminhtml\Customer\Group\Edit\Form.php


use code


class Package_Module_Block_Adminhtml_Customer_Group_Edit_Form extends Mage_Adminhtml_Block_Customer_Group_Edit_Form
{
    protected function _prepareLayout()
    {
     ///Youre code is here
     }
}

Wednesday 30 July 2014

Add multiple product images Magento

$newProduct = Mage::getModel(''catalog/product'')->load(productid)
$artworkhid = "image1.jpg,image2.jpg,image3.jpg";
$newProduct->setMediaGallery (array('images'=>array (), 'values'=>array ()));
$imgs = explode(',',$artworkhid);
 $i = 1;
foreach($imgs as $ims){
$previewImage = '/image_path/'.$ims;
     if(file_exists($previewImage)){
 if($i==1){
            $newProduct->addImageToMediaGallery ($previewImage, array ('thumbnail','small_image','image'), false, false);
      }else{
            $newProduct->addImageToMediaGallery ($previewImage, null, false, false);
  }
 $i++;
 }
}