Skip to main content

Posts

Redirect A Customer To A Custom Url/Page After Logging In Magento

if( !Mage::getSingleton( 'customer/session' )->isLoggedIn() ){     $session = Mage::getSingleton('customer/session');     $beforAutoUrl = Mage::getBaseUrl('web').$_SERVER['REQUEST_URI'];     $session->setBeforeAuthUrl($beforAutoUrl);     Mage::app()->getResponse()->setRedirect(Mage::getUrl("customer/account/login"));     }else{     echo "Operation Will Perform";    }

How to make Renderer in custom module magento

1)managedesign is my custom module 2) /app/code/local/Managedesign/Managedesign/Block/Adminhtml/Managedesign/Grid.php     call rander method:     "design_id" ia a database attribut;              $this->addColumn("design_id", array(             "header" => Mage::helper("managedesign")->__("Link"),             "index" => "design_id",             'renderer'  => 'managedesign/adminhtml_managedesign_renderer_image'                 ));                  3)crerate a folder Renderer and make a file Image.php     /app/code/local/Managedesign/Managedesign/Block/Adminhtml/Managedesign/Renderer/Image.php               class Managedesign_Managedesign_Block_Adminhtml_Managedesign_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract{           public function render(Varien_Object $row)     {         $html = '<img width="105" height="15" ';    

get directory paths, get Base URLs, get URLs in static block, get secure URL in Magento

1) Get Directory paths  Mage::getBaseDir()  //output : /var/www/html/magento Mage::getBaseDir('app')  //output : /var/www/html/magento/app Mage::getBaseDir('media') //output : /var/www/html/magento/media Mage::getBaseDir(‘design’) => Get design directory path Mage::getBaseDir(‘code’) => Gives code directory file path Mage::getBaseDir(‘lib’) => Gives lib directory file path Mage::getBaseDir(‘skin’) => Gives skin directory file path Mage::getBaseDir(‘var’) => Gives var directory file path Mage::getBaseDir(‘cache’) => Gives cache directory file path Mage::getBaseDir(‘log’) => Gives log directory file path       2) Get Base URL  Mage::getBaseUrl() => Get base url path e.g. http://yourwebsite.com/  Mage::getBaseUrl('media') => Get MEDIA folder path e.g. http://yourwebsite.com/media/  Mage::getBaseUrl('js') => Get JS folder path e.g. http://yourwebsite.com/js/  Mage::getBaseUrl('skin') => Get SKIN folder p

programaticaly Insert and select quary In magento

 INSERT QUERY include('../app/Mage.php'); Mage::app(); $write = Mage::getSingleton('core/resource')->getConnection('core_write'); $sql="INSERT INTO opd_uploads SET extension='$extension', sessionId='$sessionId', ip='$ip', status=1, dateTime=now()"; $write->query($sql); //lastInserted ID $imageId = $write->lastInsertId(); SELECT QUERY $read= Mage::getSingleton('core/resource')->getConnection('core_read');                   $value=$read->query("select * from opd_uploads WHERE id='".$imageRowId."'");          $row = $value->fetch();          $orgFilExt=$row['extension'];

Magento programmatically remove product images

/* Remove Product media Image Start*/ $ptoductId=120; $productImgRemov= Mage::getModel('catalog/product')->load($ptoductId); $entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId(); $mediaGalleryAttribute = Mage::getModel('catalog/resource_eav_attribute')->loadByCode($entityTypeId, 'media_gallery'); $gallery = $productImgRemov->getMediaGalleryImages(); foreach ($gallery as $image) $mediaGalleryAttribute->getBackend()->removeImage($productImgRemov, $image->getFile()); $productImgRemov->save(); /* Remove Product media Image End*/

Remove assign category from product

/*-----------Remove product From assign category Start------------- */ $productId=5; $product=Mage::getModel("catalog/product")->load($productId); $productIdss=$product->getId(); $all_cats = $product->getCategoryIds($productIdss);   foreach($all_cats as $_catId) { $product=Mage::getSingleton('catalog/category_api')->removeProduct($_catId,$productIdss); } /*-----------Remove product From assign category End------------- */