Tuesday, 30 June 2015

Magento send mail load by template id

                        $post = array();
                        $post['customer'] = $finelurl;
                        $postObject = new Varien_Object();
                        $postObject->setData($post);
                        $emailTemplate  = Mage::getModel('core/email_template')->load(5); //Templated id Forgot Password
                       
                        $emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/name'));
                        $emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email'));
                        $emailTemplate->setTemplateSubject('Password Reset Confirmation Hisconfe');
                        $emailTemplate->send($Secondaryemail, 'test', array('data' => $postObject));

Thursday, 18 June 2015

New order email confirmation not being sent (magento 1.9.1)

If your mail system(smtp, zend_mail) works fine; disabling mailQueue may solve your problem.

/app/code/core/Mage/Core/Model/Email/Template.php
Change Line 407
if ($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue) {

To
if (false /\*$this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue\*/) {


====================================================================
magento.stackexchange.com/questions/45571/new-order-email-confirmation-not-being-sent-magento-1-9-1

app/code/core/Mage/Checkout/Model/Type/Onepage.php line# 812 chnage $order->queueNewOrderEmail(); to $order->sendNewOrderEmail();

app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php line # change 1564 $order->queueNewOrderEmail(); to $order->sendNewOrderEmail();

Monday, 15 June 2015

programmatically get the shipping tax by order increment id in magento

$order = Mage::getModel('sales/order')->loadByIncrementId("increment_id");
//shipping cost
$shippingCost = $order->getShippingAmount();
//shipping cost in base currency
$shippingBaseCost = $order->getBaseShippingAmount();
//shipping tax
$shippingTax = $order->getShippingTaxAmount();
//shipping tax in base currenty
$shippingBaseTax = $order->getBaseShippingTaxAmount();
//shipping cost including tax
$shippingCostIncludingTax = $order->getShippingInclTax();
//shipping cost including tax in base currency
$shippingBaseCostIncludingTax = $order->getBaseShippingInclTax();

Tuesday, 9 June 2015

To get some basic order details, subtotal, shipping cost, discount, tax and grand total. Magento


$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order = Mage::getSingleton('sales/order')->loadByIncrementId($orderId);

echo "order subtotal: ".$order->getSubtotal()."<br>";
echo "shipping: ".$order->getShippingAmount()."<br>";
echo "discount: ".$order->getDiscountAmount()."<br>";
echo "tax: ".$order->getTaxAmount()."<br>";
echo "grand total".$order->getGrandTotal()."<br><br><br>";

Tuesday, 12 May 2015

Magento Previous-Next Buttons on Product Details Page

<?php
// Prev-Next links $_product = $this->getProduct(); if(!$_product->getCategoryIds()) return; // if product is not in any category, do not display prev-next :)
$cat_ids = $_product->getCategoryIds(); // get all categories where the product is located
$cat = Mage::getModel('catalog/category')->load( $cat_ids[0] ); // load first category, you should enhance this, it works for me
$order = Mage::getStoreConfig('catalog/frontend/default_sort_by');
$direction = 'asc'; // asc or desc
$category_products = $cat->getProductCollection()->addAttributeToSort($order, $direction);
$category_products->addAttributeToFilter('status',1); // 1 or 2
$category_products->addAttributeToFilter('visibility',4); // 1.2.3.4
$cat_prod_ids = $category_products->getAllIds(); // get all products from the category
$_product_id = $_product->getId();
$_pos = array_search($_product_id, $cat_prod_ids); // get position of current product
$_next_pos = $_pos+1;
$_prev_pos = $_pos-1; // get the next product url
if( isset($cat_prod_ids[$_next_pos]) ) {
$_next_prod = Mage::getModel('catalog/product')->load( $cat_prod_ids[$_next_pos] );
} else {
$_next_prod = Mage::getModel('catalog/product')->load( reset($cat_prod_ids) ); } // get the prev product url
if( isset($cat_prod_ids[$_prev_pos]) )
{
$_prev_prod = Mage::getModel('catalog/product')->load( $cat_prod_ids[$_prev_pos] );
} else {
$_prev_prod = Mage::getModel('catalog/product')->load( end($cat_prod_ids) ); } ?>
<div>
    <?php if($_prev_prod != NULL): ?>
    <a href="<?php print $_prev_prod->getUrlPath();
    if($search_parameter):?>?search=1<?php endif;?>">
    <span><?php echo $this->__('Previous') ?></span></a>
    <?php endif; ?> <?php if($_next_prod != NULL): ?> <a href="<?php print $_next_prod->getUrlPath(); if($search_parameter):?>?search=1<?php endif;?>">
    <span><?php echo $this->__('Next') ?></span></a> <?php endif; ?>
</div> 

Magento - using getPriceHtml on custom page template

<?php $_product = Mage::getModel('catalog/product')->load($product->getId());
      $productBlock = $this->getLayout()->createBlock('catalog/product_price');
      echo $productBlock->getPriceHtml($_product);
 ?>