Enlace Login/Logout
- <?php if (! Mage::getSingleton('customer/session')->isLoggedIn()): ?>
- <a href="<?php echo Mage::helper('customer')->getLoginUrl(); ?>"><?php echo $this->__('Log In') ?></a>
- <?php else: ?>
- <a href="<?php echo Mage::helper('customer')->getLogoutUrl(); ?>"><?php echo $this->__('Log Out') ?></a>
- <?php endif; ?>
Obtener el precio total de los productos del carrito
- <?php echo $this->helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal()) ?>
Obtener la descripción de la categoría en la que estamos
Añadir un producto al carrito de compra
- <a href="http://www.yourwebsite.com/magento/checkout/cart/add?product='.$_product->getId().'&qty;=1">Add To Cart</a>
Mostrar Breadcrumb (miga de pan) donde quieras
Cómo saber si estamos en la homepage o página de inicio
- <?php if(Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' && Mage::getSingleton('cms/page')->getIdentifier() == 'home') : ?>
Obtener el ID de una página CMS
- $pageId = Mage::getBlockSingleton('cms/page')->getPage()->getIdentifier();
Obtener opciones de un atributo/s
- $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'attribute_id');
- foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
- $attrubuteArray[$option['value']] = $option['label'];
- }
Cambiar el estado de un pedido
- $session = Mage::getSingleton('checkout/session');
- $order = Mage::getModel('sales/order')->load($session->getQuoteId());
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, 'processing', 'Recieved payment', $notified = true);
- $order->save();
Obtener el código de moneda
- $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
Crear un bloque para incluir un template
- <?php echo $this->getLayout()->createBlock('Mage_Adminhtml_Block_Template', 'block-name')->setData('template', 'callouts/your-file.phtml')->toHtml() ?>
Variables de sesión
- $session->setWhateverYouWant('hello');
- $session->getWhateverYouWant();
Quitar el buscador de la cabecera
- <default>
- <reference name="header">
- <action method="unsetChild"><name>topSearch</name></action>
- </reference>
- </default>
Compartir:









Loading... 


Twitter
seeal #
15 de Febrero de 2010 a las 17:16