Sunday, 31 August 2014

Magento change currency position

See the current format


Changes format

i. Go from your root folder to magento/lib/Zend/Locale/Data
ii. Find the lenguage file. In my case en.xml
iii. Look for <currencyFormatLength>


Before
<currencyFormatLength>
<currencyFormat>
<pattern>¤#,##0.00;(¤#,##0.00)</pattern>
</currencyFormat>
</currencyFormatLength>
After

<currencyFormatLength>
<currencyFormat>
<pattern>#,##0.00¤;(#,##0.00¤)</pattern>
</currencyFormat>
</currencyFormatLength>

Refresh the Magento Cache and enjoy...

Monday, 25 August 2014

Magento How to Display All Products in One Page?

Add the following line on your CMS page where you want to show all products.


{{block type="catalog/product_list" name="home.catalog.product.list" alias="products_homepage" template="catalog/product/list.phtml"}}




Friday, 22 August 2014

Display the OutofStock configurable products in the frontend - Magento

Display the OutofStock configurable products in the frontend

Go to - app\code\core\Mage\Catalog\Block\Product\View\Type\ Configurable.php

Find the following function -

public function getAllowProducts()
    {
        if (!$this->hasAllowProducts()) {
            $products = array();
            $skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck();
            $allProducts = $this->getProduct()->getTypeInstance(true)
                ->getUsedProducts(null, $this->getProduct());
            foreach ($allProducts as $product) {
                if ($product->isSaleable() || $skipSaleableCheck) {
                    $products[] = $product;
                }
            }
            $this->setAllowProducts($products);
        }
        return $this->getData('allow_products');
    }


Replace with -

public function getAllowProducts() {
        $allProducts = $this->getProduct()->getTypeInstance()->getUsedProducts();
        $this->setAllowProducts($allProducts);
        return $this->getData('allow_products');
    }

Magento Add a “mode” to Toolbar and Product Listing

Have done it by myself.

Go to - app/code/core/Mage/Adminhtml/Model/System/Config/Source/Catalog/ListMode.php

Add the highlighted code in this function :


class Mage_Adminhtml_Model_System_Config_Source_Catalog_ListMode
{
    public function toOptionArray()
    {
        return array(
            //array('value'=>'', 'label'=>''),
            array('value'=>'grid', 'label'=>Mage::helper('adminhtml')->__('Grid Only')),
            array('value'=>'list', 'label'=>Mage::helper('adminhtml')->__('List Only')),
array('value'=>'listnew', 'label'=>Mage::helper('adminhtml')->__('List New Only')),
            array('value'=>'grid-list-listnew', 'label'=>Mage::helper('adminhtml')->__('Grid (default) / List / List New')),
            array('value'=>'list-grid-listnew', 'label'=>Mage::helper('adminhtml')->__('List (default) / Grid / List New')),
array('value'=>'listnew-list-grid', 'label'=>Mage::helper('adminhtml')->__('List New (default) / Grid / List')),
        );
    }
}


then go to app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

Add the highlighted code in this function :

 protected function _construct()
    {
        parent::_construct();
        $this->_orderField  = Mage::getStoreConfig(
            Mage_Catalog_Model_Config::XML_PATH_LIST_DEFAULT_SORT_BY
        );

        $this->_availableOrder = $this->_getConfig()->getAttributeUsedForSortByArray();

        switch (Mage::getStoreConfig('catalog/frontend/list_mode')) {
            case 'grid':
                $this->_availableMode = array('grid' => $this->__('Grid'));
                break;

            case 'list':
                $this->_availableMode = array('list' => $this->__('List'));
                break;

case 'listnew':
                $this->_availableMode = array('listnew' => $this->__('List New Only'));
                break;

            case 'grid-list-listnew':
                $this->_availableMode = array('grid' => $this->__('Grid'), 'list' =>  $this->__('List'), 'listnew' =>  $this->__('List New Only'));
                break;

            case 'list-grid-listnew':
                $this->_availableMode = array('list' => $this->__('List'), 'grid' => $this->__('Grid'), 'listnew' =>  $this->__('List New Only'));
                break;


case 'listnew-list-grid':
                $this->_availableMode = array('listnew' =>  $this->__('List New Only'), 'list' => $this->__('List'), 'grid' => $this->__('Grid'));
                break;
        }
        $this->setTemplate('catalog/product/list/toolbar.phtml');
    }

Then select the list mode in admin panel

Admin - System - Configuration - Catalog - Frontend
change the list mode there.