Wednesday, August 5, 2015

Get all invoices of order in magento

 $orderId=10001;
$order = Mage::getModel('sales/order')->load($orderId);
if ($order->hasInvoices())
{
$invoiceArray = array();

foreach ($order->getInvoiceCollection() as $invoice)
{
//to see details of  invoice
echo "<pre>";
print_r($invoice);
echo "</pre>";
$invoiceArray[] = $invoice->getIncrementId();
}
}

Load Product by ID or SKU or Name

//Load by ID
$ID=1; //ID of the product
$_product = Mage::getModel('catalog/product')->load($ID);  

// Load by SKU  
$_product = Mage::getModel('catalog/product')->loadByAttribute('sku', 'myproduct'); 

// Load by Name
$_product = Mage::getModel('catalog/product')->loadByAttribute('name', 'my product');  

add hours, days, weeks, months to any date in magento

      $date = date("Y-m-d");

      $mydate = strtotime(date("Y-m-d", strtotime($date)) . " +3hours");

      $mydate = strtotime(date("Y-m-d", strtotime($date)) . " +1 day");

      $mydate = strtotime(date("Y-m-d", strtotime($date)) . " +1 week");

      $mydate = strtotime(date("Y-m-d", strtotime($date)) . " +30 days");

      $mydate = strtotime(date("Y-m-d", strtotime($date)) . " +1 month");

Get current datetime in magento

$current_datetime=date("Y-m-d H:i:s", Mage::getModel('core/date')->timestamp(time()));

Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method... magento 2

Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method and must therefore be declared abstract or implement the remaining met...