Using the following code you can obtain the Magento compare list link.
|
1 |
Mage::helper('catalog/product_compare')->getListUrl(); |
Using the following code you can obtain the Magento compare list link.
|
1 |
Mage::helper('catalog/product_compare')->getListUrl(); |
The Magento compare list link is shown on the category page by default. Using the following code you can add it to the Magento product page as well.
|
1 |
<a href="<?php echo Mage::helper('catalog/product_compare')->getAddUrl($_product);?>">link text</a> |
Using the following code, you can obtain the tracking information of a Magento order.
|
1 2 3 4 |
$trackingCollection = $order->getTracksCollection(); $firstItem = $trackingCollection->getFirstItem(); $trackingNumber = $firstItem->getNumber(); ... |
Use the following code to get a products attribute set name.
|
1 2 3 |
$attributeSetModel = Mage::getModel("eav/entity_attribute_set"); $attributeSetModel->load($product->getAttributeSetId()); $attributeSetName = $attributeSetModel->getAttributeSetName(); |
For whatever reason, the JavaScript console is not working for Magento by default. So if you try to output messages using console.log, nothing will happen. To change that, open js\varien\js.js and uncomment the following code:
|
1 2 3 4 5 6 7 8 9 |
if (!("console" in window) || !("firebug" in console)) { var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; window.console = {}; for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {} } |
Open your .htaccess file in the Magento root directory and add those lines:
|
1 2 3 |
RewriteCond %{request_method} ^GET$ RewriteCond %{REQUEST_URI} ^(.+)/$ RewriteRule ^(.+)$ %1 [L,R=301] |
Magento automatically adds the defined suffix to the title tag on every page. If you want to change that for lets say the home page, open the CMS page “home” and add the following XML to the layout section:
|
1 2 3 |
<reference name="head"> <action method="setData"><key>title</key><value>... Title Tag ...</value></action> </reference> |
Use the following code to get a Magento categories parent category.
|
1 |
Mage::getSingleton('catalog/layer')->getCurrentCategory()->getParentCategory(); |
While being on the Magento category page, it might be useful to display the category name. Use the following code to do so.
|
1 |
Mage::getSingleton('catalog/layer')->getCurrentCategory()->getName(); |
To get the order data on the Magento success page, use the following code. The key here is to create an order object and get the data from there.
|
1 2 3 |
$order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId()); $date = $order->getCreatedAtStoreDate(); // ... |