Monday 11 April 2016

Enable template path hint in admin Panel - Magento

There are two ways to enable admin panel path hints.

1.
You can enable template and block path hints in every store (including the admin store) by setting them in the Magento configuration. To do this, simply edit your module's configuration file app/etc/config.xml (which gets injected into Magento's global configuration).

To enable template and block path hints in the admin area add this to your app/etc/config.xml file
<config>

    ...

    <stores>
        <admin>
            <dev>
                <debug>
                    <template_hints>1</template_hints>
                    <template_hints_blocks>1</template_hints_blocks>
                </debug>
            </dev>
        </admin>
    </stores>
</config>
To disable path hints simply change to 0, or delete the node.

2.

You can do it by changing the database directly. If you have something like phpMyAdmin that is a good way to gain access. Enter this SQL.

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

When you are done with path hints just delete the matching record from core_config_data Or update the value field to 0 instead of deleting the whole record, it will probably be the last one since you've just added it.

Saturday 9 April 2016

How to get last week' date range in PHP, Codeigniter, CakePHP

$previous_week = strtotime("-1 week +1 day");
$start_week = strtotime("last sunday midnight",$previous_week);
$end_week = strtotime("next saturday",$start_week);
$start_week = date("Y-m-d",$start_week);
$end_week = date("Y-m-d",$end_week);
echo $start_week.' '.$end_week ;

Monday 4 April 2016

How to add 00 after a number in php

$value = 100.25;
echo number_format($value, 2);

Curl automatically display the result? / Without print, response is displayed me in CURL php

By default, the curl extension prints out the result.
You need to enable the CURLOPT_RETURNTRANSFER option, like so:

curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

After that option is enabled, curl_exec will return the result, instead.

Thursday 31 March 2016

How to create import functionality on grid page in magneto


Open Grid.php
protected function _prepareMassaction()
    {
..................
..................
//Upload your csv file into var/import directory
$dir = new DirectoryIterator(Mage::getBaseDir() . DS . 'var' . DS . 'import' . DS);
$extensions = "csv";
$csv = array();
foreach ($dir as $fileinfo) {
    if ($fileinfo->isFile() && stristr($extensions, $fileinfo->getExtension())) {
        $csv[$fileinfo->getFilename()] = $fileinfo->getFilename();
    }            
}
$csv = array_merge(array(''=>'Please select'),$csv);
$this->getMassactionBlock()->addItem('import', array(
    'label'        => Mage::helper('metizsoft_taxgenerate')->__('Import'),
    'url'          => $this->getUrl('*/*/massCsv', array('_current'=>true)),
    'confirm'  => Mage::helper('metizsoft_taxgenerate')->__('Are you sure?'),
    'additional'   => array(
        'subgroup'    => array(
            'name'     => 'csv',
            'type'     => 'select',
            'class'    => 'required-entry',
            'label'    => Mage::helper('customer')->__('Select Csv'),
            'values'   => $csv
        )
    )
));
return $this;
}

Open your controller file. and put this code.public function massCsvAction()
{
$csvfile = $this->getRequest()->getParam('csv');
if (!$csvfile) {
  Mage::getSingleton('adminhtml/session')->addError(
      Mage::helper('metizsoft_taxgenerate')->__('Please select statetaxs.')
  );
} else {
  try {
     $csv = new Varien_File_Csv;
     $csvpath = Mage::getBaseDir() . DS . 'var' . DS . 'import' . DS . $csvfile;
             
     $datas = $csv->getData($csvpath);
     print_r($datas);
   } catch (Mage_Core_Exception $e) {
     Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
   } catch (Exception $e) {
     Mage::getSingleton('adminhtml/session')->addError(
        Mage::helper('metizsoft_taxgenerate')->__('There was an error updating statetaxs.')
     );
     Mage::logException($e);
   }
}
$this->_redirect('*/*/index');
}

Monday 28 March 2016

How to get Controller, Action/Function/Method, URL informations in CodeIgniter PHP

You could use the URI Class:
$this->uri->segment(n); // n=1 for controller, n=2 for method, etc
You can also use this in-built functions of codeigniter.
$this->router->fetch_class();
$this->router->fetch_method(); 

Saturday 26 March 2016

Remove specific color/white/Black from any type of image

//header('Content-type: image/png');
$strInputFile = '20160312105210_girls.jpg';
$target = 'car_transparent.png';
$im = new Imagick($strInputFile);
//$im->paintTransparentImage($im->getImageBackgroundColor(), 0, 10000);
$im->paintTransparentImage('#000', 0, 10000); //Which color you need to remove #000
$im->setImageFormat('png');
//$im->writeImage($target);
$im->destroy();
//echo $im;