Tag Archives: Magento tutorials online
Magento get store url
Magento get store url : You can get the store url in magento as following.
Magento get store url Syntax
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
Which Will Return the store url.
For Cms Pages Or Static Blocks
{{store url='/yourpage.html'}}
Magento get js url
Magento get js url : You can get the js url in magento as following.
Magento get js url Syntax
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
Which Will Return the Js url.
Magento get media url
Magento get media url : Here are following ways to get the media url in magento.
Magento get media url Syntax
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
Which Will Return the media url.
For Cms Pages Or Static Blocks
{{media 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.