Category Archives: Magento
Magento get skin url
Magento get skin url : Here are following ways to get the skin url in magento.
Magento get skin url
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
Unsecure Url
$this->getSkinUrl('images/myimage.jpg');
Secure Url
$this->getSkinUrl('images/myimage.jpg', array('_secure'=>true));
For Cms Pages Or Static Blocks
{{skin url='/yourimagename.jpg'}}
Magento get current url without parameters
Magento get current url without parameters : Magento Get Current url without the parameter as
Magento get current url without parameters Syntax
$request = $this->getRequest(); $urlWithoutParameters = Mage::getBaseUrl(). $request->getRouteName() .'/'. $request->getControllerName() .'/'. $request->getActionName();
Which will return the current url without the including the base url
Magento get current url without parameters Example
http://example.com/category/fashion/latest
Magento get current url path
Magento get current url path : You can get current url path as
Magento get current url path Syntax
$currentUrl = Mage::helper('core/url')->getCurrentUrl(); $url = Mage::getSingleton('core/url')->parseUrl($currentUrl); $path = $url->getPath();
Which will return the current url path.
Magento get Current url path Example
category/fashion/latest
Magento get current url
Magento get current url : Magento Get Current url as
Magento get Current url Syntax
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
Which will return the current url including the base url
Magento get Current url Example
http://example.com/category/fashion/latest
Magento get coupon codes used by customer
Magento get coupon codes used by customer : You Can Get Coupon code used by particular user by following query.
Syntax : Magento get coupon codes used by customer
$collection = Mage::getModel('sales/order')->getCollection(); $collection->getSelect()->join(array('coupon'=> salesrule_coupon), 'coupon.code = main_table.coupon_code', array('coupon.type')) ->join( array('coupon_usage'=> salesrule_coupon_usage), '(coupon_usage.coupon_id = coupon.coupon_id AND coupon_usage.customer_id = "'.$customerId.'") ', array('*')); //pass customer Id to load coupon used by the customer - $customerId
$customerId – is customer id, load coupon codes used by this customer
Magento get coupon code applied on cart
Magento get coupon code applied on cart : You Can get coupon code applied on cart from the current quote.
Magento get coupon code applied on cart Syntax
$couponCode = Mage::getSingleton('checkout/session') ->getQuote() ->getCouponCode();
Which will return the coupon code applied on the magento current cart’s item.
Magento get current customer group id
Magento get current customer group id : Mage::getSingleton(‘customer/session’)->getCustomerGroupId(); is used to get current customer group id.
Syntax: Magento get current customer group id
$isLogin = Mage::getSingleton( 'customer/session' )->isLoggedIn(); if( $isLogin ){ $customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId(); }else{ $customerGroupId = ''; }
This will return the current customer’s group id.
Magento custom admin module 404 after security patch installation
Magento custom admin module 404 after security patch installation :
This error occurs when you install security patch. Because security path overrides the method is_allowed which return false.
Add the following method in your controller to override the default method to fix the 404 error.
protected function _isAllowed() { return true; }
Which will solve your problem.
Magento set default value for config defined value
Magento set default value for config defined value
Add the following code in your config.php file under the
My Default Value
Example :
system.xml file
309 352 1 1 1 Your_tab 12 1 1 1 text 1 1 1 1 Your settings.
For Setting The default value of the field : demo_field you have to add following code in config.xml
0.1.0 YourCompany_Your_module_Helper 101 1
Which will look with default value 1 as :

magento set default value for config defined value