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.







Friday, 18 July 2014

Magento Delete all orders and customer data

Please make sure that keep backup of your magento database before running this query.



SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_status_history`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_order_payment`;
TRUNCATE `sales_flat_quote_payment`;
TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
TRUNCATE `customer_address_entity`;
TRUNCATE `customer_address_entity_datetime`;
TRUNCATE `customer_address_entity_decimal`;
TRUNCATE `customer_address_entity_int`;
TRUNCATE `customer_address_entity_text`;
TRUNCATE `customer_address_entity_varchar`;
TRUNCATE `customer_entity`;
TRUNCATE `customer_entity_datetime`;
TRUNCATE `customer_entity_decimal`;
TRUNCATE `customer_entity_int`;
TRUNCATE `customer_entity_text`;
TRUNCATE `customer_entity_varchar`;
TRUNCATE `log_customer`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;
ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `log_customer` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;
TRUNCATE `eav_entity_store`;
ALTER TABLE `eav_entity_store` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;

Sunday, 6 April 2014

Magento admin panel template hints

1st Time

INSERT INTO core_config_data (scope, scope_id, path, value)
VALUES ('default', 0, 'dev/debug/template_hints', 1),
('default', 0, 'dev/debug/template_hints_blocks', 1);


Deactivate
_______________________________
UPDATE core_config_data set value = 0 where scope = 'default' and scope_id = 0 and path ='dev/debug/template_hints';


2nd Time
____________________________
UPDATE core_config_data set value = 1 where scope = 'default' and scope_id = 0 and path ='dev/debug/template_hints';

Thursday, 27 March 2014

How to set minimum quantity in magento cart?

Go to app\design\frontend\base\default\template\checkout\onepage\link.phtml


Put this code in this page


<?php if ($this->isPossibleOnepageCheckout()):?>
<?php if(Mage::helper('checkout/cart')->getCart()->getItemsQty() >= 3):?>
    <button type="button" title="<?php echo $this->__('Proceed to Checkout') ?>" class="button btn-proceed-checkout btn-checkout<?php if ($this->isDisabled()):?> no-checkout<?php endif; ?>"<?php if ($this->isDisabled()):?> disabled="disabled"<?php endif; ?> onclick="window.location='<?php echo $this->getCheckoutUrl() ?>';"><span><span><?php echo $this->__('Proceed to Checkout') ?></span></span></button>
<?php else:?>
<font style="color:red;">You must order a quantity of 3 or more to proceed.</font>
<?php endif?>
<?php endif?>


Then put this code into header.phtml page

<input type="hidden" id="get_cart" value="<?php echo Mage::helper('checkout/cart')->getCart()->getItemsQty(); ?>" />
<script type='text/javascript'>
        jQuery(document).ready(function() {
if(document.getElementById("get_cart").value < 3) {
jQuery(".top-link-checkout").attr("href", "javascript:void(0);")
}
        });

</script>

Then enjoy!!!!!!!!!!!!!!