Archive for July 2019

Magento create Creditmemo to refund online or offline

<?php   $orderId =’123456789′; $invoiceId = ‘1234’;   $data = array( ‘items’ => array( ‘12345’ => array(’qty’ => ‘1’), ‘12346’ => array(’qty’ => ‘2’) ), ‘comment_text’ => null, ‘do_offline’ => 1, ‘shipping_amount’ => 0, ‘adjustment_positive’ => ‘0’, ‘adjustment_negative’ => ‘0’, ‘refund_customerbalance_return_enable’ => 1, ‘refund_customerbalance_return’ => 39.9 );   // load order and invoice $order = […]

Magento get order invoice id and order items

<?php $orderId = ‘1234567890’; $order = Mage::getModel(’sales/order’)->load($orderId);   if ($order->hasInvoices()) { $invoiceIds = $order->getInvoiceCollection()->getAllIds(); $invoiceId = $invoiceIds[0]; echo ‘invoiceId: ‘.$invoiceId."\n"; }   foreach ($order->getAllItems() as $item) { echo $item->getId().’->’.$item->getQtyOrdered()."\n"; }

Images media folder

Magento keeps images under media/catalog/product/ folder, full path to the file in adminhtml can be for example media/catalog/product/[1st_letter_of_filename]/[2nd_letter_of_filename]/filename.jpg In frontend images loaded from media/catalog/product/cache/ folder, full path to cache file in frontend can be for example media/catalog/product/cache/image/*, media/catalog/product/cache/small_image/* and media/catalog/product/cache/thumbnail/* When we do System -> Cache Management -> Flush Catalog Images Cache it deleted entire […]