Tag: Magento

  • Magento – Inspect the Data Passed Through Observer Events

    [php] echo “<pre>”; var_dump($observer->getDataObject()->getData()); [/php]

  • Magento – Show Address Fields in Customer Registration Form

    Open up your local.xml or any xml file that you are using with your theme. Add the following bit: [xml] <customer_account_create> <reference name=”customer_form_register”> <action method=”setShowAddressFields”> <param>true</param> </action> </reference> </customer_account_create> [/xml] You will notice a code in the register.phtml file found here: /app/design/frontend/base/default/template/customer/form/register.phtml [php] if($this->getShowAddressFields()): [/php] This is the condition that shows the customer address related…

  • Magento – Get Current Package Name and Theme Name

    // To get the current package name of the Magento store / site Mage::getSingleton(‘core/design_package’)->getPackageName(); // To get the current theme of the Magento store / site Mage::getSingleton(‘core/design_package’)->getTheme(‘frontend’); // You can pass ‘locale’, ‘layout’, ‘template’, ‘default’, or ‘skin’ into the above function.

  • Magento – Disable Toolbar Sort / Order By Memory Cookie

    [xml] <reference name=”product_list_toolbar”> <action method=”disableParamsMemorizing”/> </reference> [/xml]

  • Magento – Adding a Custom Category Attribute (EAV)

    [php] $setup = new Mage_Eav_Model_Entity_Setup(‘core_setup’); $setup->startSetup(); $setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, ‘show_sale_icon’, array( ‘backend’ => ”, ‘default’ => 0, ‘global’ => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, ‘group’ => ‘General’, ‘input’ => ‘select’, ‘label’ => ‘Show Category Sale Icon’, ‘position’ => 100, ‘required’ => false, ‘source’ => ‘eav/entity_attribute_source_boolean’, ‘type’ => ‘int’, ‘user_defined’ => true, ‘visible’ => true, ‘visible_on_front’ => true, ) ); $setup->endSetup(); [/php]…

  • Magento Fix – Email Validation for New gTLDs

    Have you come across the following errors in Magento? Invalid email address “[email protected]” “[email protected]” is not a valid hostname. ‘domain.events’ appears to be a DNS hostname but cannot match TLD against known list ‘domain.events’ appears to be a local network name but local network names are not allowed It is probably because the Zend email…

  • Magento – Reset File and Folder Permissions

    You might have come across the following error while in Magento Connect Manager – Warning: Your Magento folder does not have sufficient write permissions. Magento needs certain file and folder permissions to be able to automatically performs upgrades and module installs. Open your SSH and browse to your root folder. Then, run the following commands.…

  • Magento – Get CMS Static Block Model Data (Title, Status, Content)

    You can store template and HTML data in Magento’s static blocks. If you want to pull it into your PHTML templates, just call load up the model and use the data fields. [php] <?php $staticBlock = Mage::getModel(‘cms/block’)->load(‘static-block-identifier’); echo $staticBlock->getTitle(); echo $staticBlock->getIdentifier(); echo $staticBlock->getIsActive(); echo $staticBlock->getContent(); ?> [/php]

  • Magento – Check if CMS Static Block is Enabled / Active

    Static blocks in Magento are really useful. They offer an easy way to insert content into various parts of the template. You are only limited by your imagination. You can check if the static blocks are enabled, before printing them to screen. [php] <?php if(Mage::getModel(‘cms/block’)->load(‘static-block-identifier’)->getIsActive()) : echo Mage::app()->getLayout()->createBlock(‘cms/block’)->setBlockId(‘static-block-identifier’)->toHtml(); endif; ?> [/php]

  • Magento – Get Logged In Customer’s Group ID

    [php] <?php /* Check if customer is logged in */ $isLoggedIn = Mage::getSingleton(‘customer/session’)->isLoggedIn(); /* If customer is logged in */ if($isLoggedIn) : /* Get the logged in customer’s group ID */ $customerGroupId = Mage::getSingleton(‘customer/session’)->getCustomerGroupId(); /* Check if the logged in customer’s group ID matches with the ID you are after */ /* Customer group IDs…

  • Magento Fix – Blank Index Management Page (caused by GeoIP)

    Do you get a blank page when navigating to your Index Management section of Magento admin? It could be that you have Openstream’s GeoIP module and that module is conflicting with Magento’s core. Navigate to app/code/community/Openstream/GeoIP/etc/config.xml (line 47) and make the changes shown below. [xml] <adminhtml> <layout> <updates> <index> <geoip> <!– Added –> <file>openstream/geoip.xml</file> </geoip>…

  • Magento – Export All Customers to CSV with Billing and Shipping Address

    <?php require_once(‘app/Mage.php’); umask(0); Mage::app(); $customers = Mage::getModel(‘customer/customer’)->getCollection(); $customers->addAttributeToSelect(‘*’); $customersArray[0] = array( ‘entity_id’, ’email’, ‘prefix’, ‘firstname’, ‘middlename’, ‘lastname’, ‘suffix’, ‘website_id’, ‘store_id’, ‘group_id’, ‘created_at’, ‘updated_at’, ‘is_active’, ‘is_subscribed’, ‘billing_firstname’, ‘billing_lastname’, ‘billing_street_1’, ‘billing_street_2’, ‘billing_city’, ‘billing_region_id’, ‘billing_region’, ‘billing_postcode’, ‘billing_country_id’, ‘billing_telephone’, ‘shipping_firstname’, ‘shipping_lastname’, ‘shipping_street_1’, ‘shipping_street_2’, ‘shipping_city’, ‘shipping_region_id’, ‘shipping_region’, ‘shipping_postcode’, ‘shipping_country_id’, ‘shipping_telephone’ ); $i = 1; foreach ($customers as $key => $customer)…