Saturday, 2 June 2018

How can I display indian price symble properly in invoice pdf in magento 1.9

1.Download the font that support Indian Rupee symbol. recommended dejavu-sans font.

2.place the font in lib directory.
3.open app/code/core/Mage/Sales/Model/Order/Pdf/Abstract.php and app/code/core/Mage/Sales/Model/Order/Pdf/Items/Abstract.php

and replace
$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/LinLibertineFont/LinLibertine_Re-4.4.1.ttf');

With
$font = Zend_Pdf_Font::fontWithPath(Mage::getBaseDir() . '/lib/dejavu-sans/DejaVuSans.ttf');

(in _setFontRegular(), _setFontBold(), _setFontItalic() functions in both files.)
 

Friday, 1 June 2018

How to get data from Magento 1.9 System Configuration

<?php
$store = Mage::app()->getStore(); // store info
$configValue = Mage::getStoreConfig('sectionName/groupName/fieldName', $store);
?>
example
<?php
$store = Mage::app()->getStore(); // store info
$configValue = Mage::getStoreConfig('rene_banner_settings/rene_banner_rule/igstnumber', $store);
?>

Admin config with extendable amount of fields system.xml in magento 1.9

app/code/local/Abhi/Banner/etc/system.xml

<config>
    <sections>
        <abhi_banner_settings translate="label" module="banner">
             <label>HSN Number Settings</label>
            <tab>general</tab>
            <frontend_type>text</frontend_type>
            <sort_order>304</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <abhi_banner_rule translate="label">
                    <label>HSN </label>
                    <frontend_type>text</frontend_type>
                    <sort_order>10</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>

                        <hsnnumber translate="label">
                            <label>HSN Number</label>
                            <frontend_type>text</frontend_type>
                            <sort_order>10</sort_order>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </hsnnumber>
                    </fields>
                </abhi_banner_rule>
            </groups>
        </abhi_banner_settings>
    </sections>
</config>

===============================
app/code/local/Abhi/Banner/etc/adminhtml.xml

<config>
    <acl>
        <resources>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <abhi_banner_settings translate="title">
                                        <title>HSN Number Settings</title>
                                        <sort_order>55</sort_order>
                                    </abhi_banner_settings>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
</config>

get value:-
<?php
$store = Mage::app()->getStore(); // store info
echo $configValue = Mage::getStoreConfig('abhi_banner_settings/abhi_banner_rule/hsnnumber', $store);
?>

Tuesday, 17 April 2018

How to get current Currency and symbol in PHTML File in magento 2 ?


    <?php
        $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $currencysymbol = $_objectManager->get('Magento\Store\Model\StoreManagerInterface');
        $currencyCode = $currencysymbol->getStore()->getCurrentCurrencyCode();
        $currency = $_objectManager->create('Magento\Directory\Model\CurrencyFactory')->create()->load($currencyCode);
        $currencySymbol = $currency->getCurrencySymbol();
    ?>

Magento 2 How can I show custom options on product list page?



<?php
     $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();

    $customOptions = $_objectManager->get('Magento\Catalog\Model\Product\Option')->getProductOptionCollection($_product);
    $optStr = "";
    foreach($customOptions as $optionKey => $optionVal):
        $optStr .= "<div class='custom-options'><label>".$optionVal->getTitle()." </label>";
            $optStr .= "<select name='options[".$optionVal->getId()."]'>";
            foreach($optionVal->getValues() as $valuesKey => $valuesVal) {
            $optStr .= "<option value='".$valuesVal->getId()."'>".$valuesVal->getTitle()."</option>";
                }

        $optStr .= "</select></div>";
    endforeach;
       echo($optStr );

?>

How to select option onchange url redirection

How to select option onchange url redirection:

<select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">
<option value="" selected>---Select---</option>
<option value="https://www.google.com">Google</option>
<option value="https://www.google.com">Google</option>
<option value="https://www.google.com">Google</option>
<option value="https://www.google.com">Google</option>
</select>

Monday, 9 April 2018

How to display percentage of discount on product list and product view page in magento1.9?

How to display percentage of discount on product list and product view page in magento1.9?

app/design/frontend/yourpackage/yourtheme/template/catalog/product/price.phtml

Find: (line 397)

<?php endif; /* if ($_finalPrice == $_price): */ ?>

Past above it:

<?php // Discount percents output start ?>
    <?php if($_finalPrice < $_price): ?>
    <?php $_savePercent = 100 - round(($_finalPrice / $_price)*100); ?>
        <p class="special-price yousave">
            <span class="label"><?php echo $this->__('You Save:') ?></span>
            <span class="price">
                <?php echo $_savePercent; ?>%
            </span>
        </p>
    <?php endif; ?>
<?php // Discount percent output end ?>