Search the Community
Showing results for tags 'magento'.
-
I am using magento for sending mail with condition, My code: <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $extra = $order->getIncrementId(); $message = " <tr> <!-- <td>$incrementid</td> --> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = " <p>Order Id : $incrementid</p> <table border='1'> <tr> <!-- <th>Id</th> --> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMail($finalMessage); } } public function sendMail($message) { $body ="$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('abc'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $emailTemplate->setToEmail('abc@gmail.com'); $emailTemplate->send(); } } ?> Output : If order placed mail send to abc@gmail.com. How to set email sender based on SKU $sku from order. I want : 1) If SKU starts with 2, email should go to the mail id abc@gmail.com, screenshot : 2) If SKU starts with 3, email should go to the mail id xyz@gmail.com, screenshot : 3) If SKU starts with 4, email should go to the mail id qwe@gmail.com, screenshot : FYI - If an order contains 10 items email should go separately based on SKU. But an order id the same must include all the emails.
-
Magento PHP mail function : <?php class Gta_MerchantNotification_Model_Observer { public function merchantremainder($Observer) { $order = $Observer->getEvent()->getOrder(); $order_details = $order->getAllVisibleItems(); $itemData = array(); foreach ($order_details as $list) { $incrementid = $order->getIncrementId(); $sku = $list->getsku(); $name = $list->getName(); $price = $list->getPrice(); $Qty = $list->getQtyOrdered(); $extra = $order->getIncrementId(); $message = " <tr> <td>$incrementid</td> <td>$sku</td> <td>$name</td> <td>$price</td> <td>$Qty</td> </tr>"; $itemData[$list->getId()] = $message; } $finalMessage = "<table border='1'> <tr> <th>Id</th> <th>Sku</th> <th>Product name</th> <th>Price</th> <th>Qty Ordered</th> </tr>"; if (!empty($itemData)) { foreach ($itemData as $data) { $finalMessage .= $data; } $finalMessage .= "</table>"; $this->sendMail($finalMessage); } } public function sendMail($message) { $body ="$message"; $emailTemplate = Mage::getModel('core/email'); $emailTemplate->setFromName('abc'); $emailTemplate->setBody($body); $emailTemplate->setSubject("Custom Email from observer"); $emailTemplate->setType('html'); $emailTemplate->setToEmail('aveevacool@gmail.com'); $emailTemplate->send(); } } ?> Now my output like :
-
Magento 1.9 - How to include custom PHP Script into .PHTML file My magento tracking page: https://i.stack.imgur.com/3GIoN.png Back-end magento code : https://i.stack.imgur.com/ySgMA.png How can i add my PHP script into this tracking page. Tracking page code - trackorder.phtml [ https://i.stack.imgur.com/ySgMA.png ] <?php if(Mage::getStoreConfig('trackorder/trackorder_general/enabled')): ?> <div class="page-title"><h1><?php echo $this->__('Track Your Order ') ?></h1></div> <div class="form-list"> <form name="track_order" id="track_order" action="" method="post" onsubmit="sendAjax('track_order','<?php echo Mage::getUrl('*/*/track');?>'); return false;"> <!--<form name="track_order" method="post" id="track_order" action="<?php echo Mage::getUrl('*/*/view');?>">--> <ul class="form-list"> <li> <label for="order_id" class="required"><em>*</em><?php echo $this->__('Order Id') ?></label> <div class="input-box"> <input type="text" name="order_id" id="order_id" value="" title="" class="input-text required-entry" /> </div> </li> <li> <label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label> <div class="input-box" > <input type="text" name="email" id="email_address" value="" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" /> </div> </li> </ul> <div class="buttons-set"> <button type="submit" class="button" title="<?php echo $this->__('Track Order') ?>" name="track" id="track"> <span><span><?php echo $this->__('Track Order') ?></span></span> </button> </div> </form> <div id="loading-details" class="loading-details" style="display:none"> <div id="loading-mask" > <p class="loader" id="loading_mask_loader"><img src="<?php echo $this->getSkinUrl('trackorder/images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('adminhtml')->__('Loading...') ?>"/><br/><?php echo $this->__('Please wait...') ?></p> </div> </div> </div> <div id="oderinfo" class="order-info-message"></div> <script type="text/javascript"> var validateForm = new VarienForm('track_order', true); </script> <script type="text/javascript"> function sendAjax(frmId,url){ if (!validateForm.validator.validate()) { return; } var data = $(frmId).serialize(this); $("loading-details").show(); new Ajax.Updater( { success:"oderinfo" }, url, { asynchronous:true, evalScripts:false, onComplete:function(request, json){ $("loading-details").hide(); return false; }, onLoading:function(request, json){}, parameters:data } ); return false; } </script> <?php else: ?> <?php $url = Mage::getBaseUrl(); Mage::app()->getFrontController()->getResponse()->setRedirect($url); ?> <?php endif; ?> From above code how can i add my own PHP script : My PHP script : <!DOCTYPE HTML> <html> <body> <form action="#" method="POST"> Select Courier : <select name="courier"> <option disabled='disabled' selected>-- Choose an option --</option> <option value="professional_courier">Professional Courier</option> <option value="shree_maruti_courier">Shree Maruti Courier</option> <option value="india_post_courier">India Post Courier</option> <option value="dhl_courier">DHL Courier</option> <option value="fedex_courier">Fedex Courier</option> <option value="ups_courier">UPS Courier</option> </select> Trackingid: <input type="text" name="trackingid"> <input type="submit"> </form> <?php if (isset($_POST['courier'])) { // Professional Courier if ('professional_courier' === $_POST['courier']) { header("Location: https://www.tpcindia.com/Tracking2014.aspx?id=" . $_POST["trackingid"] . "&type=0&service=0"); } // Shree Maruti Courier else if ('shree_maruti_courier' === $_POST['courier']) { header("Location: https://www.shreemaruticourier.com/track-your-shipment/#track-your", "_blank"); } // india_post_courier else if ('india_post_courier' === $_POST['courier']) { header("Location: https://www.indiapost.gov.in/vas/Pages/IndiaPostHome.aspx/#main-content", "_blank"); } // DHL Courier else if ('dhl_courier' === $_POST['courier']) { header("Location: https://www.dhl.com/en/express/tracking.html?AWB=" . $_POST["trackingid"] . "&brand=DHL", "_blank"); } // Fedex Courier else if ('fedex_courier' === $_POST['courier']) { header("Location: https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=" . $_POST["trackingid"] . "&cntry_code=in&locale=en_IN", "_blank"); } // ups_courier else if ('ups_courier' === $_POST['courier']) { header("Location: https://www.ups.com/track?loc=en_US&tracknum=" . $_POST["trackingid"] . "&requester=WT/trackdetails", "_blank"); } } ?> </body> </html> My Workout in trackorder.phtml getting error : [start & end header added] <?php if(Mage::getStoreConfig('trackorder/trackorder_general/enabled')): ?> <div class="page-title"><h1><?php echo $this->__('Track Your Order ') ?></h1></div> <div class="form-list" style="float: left;"> <form name="track_order" id="track_order" action="" method="post" onsubmit="sendAjax('track_order','<?php echo Mage::getUrl('*/*/track');?>'); return false;"> <!--<form name="track_order" method="post" id="track_order" action="<?php echo Mage::getUrl('*/*/view');?>">--> <ul class="form-list"> <li> <label for="order_id" class="required"><em>*</em><?php echo $this->__('Order Id') ?></label> <div class="input-box"> <input type="text" name="order_id" id="order_id" value="" title="" class="input-text required-entry" /> </div> </li> <li> <label for="email_address" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label> <div class="input-box" > <input type="text" name="email" id="email_address" value="" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" /> </div> </li> </ul> <div class="buttons-set"> <button type="submit" class="button" title="<?php echo $this->__('Track Order') ?>" name="track" id="track"> <span><span><?php echo $this->__('Track Order') ?></span></span> </button> </div> </form> <div id="loading-details" class="loading-details" style="display:none"> <div id="loading-mask" > <p class="loader" id="loading_mask_loader"><img src="<?php echo $this->getSkinUrl('trackorder/images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('adminhtml')->__('Loading...') ?>"/><br/><?php echo $this->__('Please wait...') ?></p> </div> </div> </div> <!-- Start couier tracking --> <div style="float: left;"> <form action="#" method="POST" style="padding: 28px 15px 21px 196px;"> Select Courier : <select name="courier"> <option disabled='disabled' selected>-- Choose an option --</option> <option value="professional_courier">Professional Courier</option> <option value="shree_maruti_courier">Shree Maruti Courier</option> <option value="india_post_courier">India Post Courier</option> <option value="dhl_courier">DHL Courier</option> <option value="fedex_courier">Fedex Courier</option> <option value="ups_courier">UPS Courier</option> </select> Trackingid: <input type="text" name="trackingid"> <input type="submit"> </form> <?php if (isset($_POST['courier'])) { // Professional Courier if ('professional_courier' === $_POST['courier']) { header("Location: https://www.tpcindia.com/Tracking2014.aspx?id=" . $_POST["trackingid"] . "&type=0&service=0"); } // Shree Maruti Courier else if ('shree_maruti_courier' === $_POST['courier']) { header("Location: https://www.shreemaruticourier.com/track-your-shipment/#track-your", "_blank"); } // india_post_courier else if ('india_post_courier' === $_POST['courier']) { header("Location: https://www.indiapost.gov.in/vas/Pages/IndiaPostHome.aspx/#main-content", "_blank"); } // DHL Courier else if ('dhl_courier' === $_POST['courier']) { header("Location: https://www.dhl.com/en/express/tracking.html?AWB=" . $_POST["trackingid"] . "&brand=DHL", "_blank"); } // Fedex Courier else if ('fedex_courier' === $_POST['courier']) { header("Location: https://www.fedex.com/apps/fedextrack/?action=track&trackingnumber=" . $_POST["trackingid"] . "&cntry_code=in&locale=en_IN", "_blank"); } // ups_courier else if ('ups_courier' === $_POST['courier']) { header("Location: https://www.ups.com/track?loc=en_US&tracknum=" . $_POST["trackingid"] . "&requester=WT/trackdetails", "_blank"); } } ?> </div> <!-- End couier tracking --> <div id="oderinfo" class="order-info-message"></div> <script type="text/javascript"> var validateForm = new VarienForm('track_order', true); </script> <script type="text/javascript"> function sendAjax(frmId,url){ if (!validateForm.validator.validate()) { return; } var data = $(frmId).serialize(this); $("loading-details").show(); new Ajax.Updater( { success:"oderinfo" }, url, { asynchronous:true, evalScripts:false, onComplete:function(request, json){ $("loading-details").hide(); return false; }, onLoading:function(request, json){}, parameters:data } ); return false; } </script> <?php else: ?> <?php $url = Mage::getBaseUrl(); Mage::app()->getFrontController()->getResponse()->setRedirect($url); ?> <?php endif; ?>
-
I've been given an unfortunate task of working with magento. My question might be magento-specific, but I'm not sure that it is. In short, I'm troubleshooting something and confused. This code... $user = $this->getUser(); ...would seem to be quite easy to troubleshoot, but it is not. The current class has no getUser function. Its base class has no getUser function. If I print a debug statement to examine $this, the class I'm looking at -- Session -- isn't the class at all! $this is some other class! In fact, the class that is shown doesn't exist anywhere in the source code. So... what the heck? How can $this not be $this ??
- 4 replies
-
- magento
- interceptors
-
(and 1 more)
Tagged with:
-
Hello Guys, I have an interesting issue in Magento. After a site backup and transfer onto a new domain the front-end of my website loads fine, however when I try to navigate to: domain.com/index.php/admin I get a white page. I have enabled debugging mode and it displays this error: 1 Array ( [type] => 64 [message] => Cannot redeclare class Mage_Admin_Model_Session [file] => /var/www/vhosts/domain.co.uk/sub-domain.co.uk/includes/src/__adminhtml.php [line] => 504 ) Since finding this new error, I've tried to comment/remove every class that it cannot redeclare in the __adminhtml.php file, one by one.. Only to find that by the time I've commented them all out and refreshed the admin page, it gives no error whatsoever. Just a white page. Any ideas? Any help is much appreciated.
-
Hello Friends, I am working as a Php Developer since last 5+ years. I have strong knowledge in Php/MySql, WordPress, Opencart and Magento. You can check my portfolio here..http://phpfreelancerszone.com/php-portfolio/ Contact Us By Email:shailpatel05@gmail.com We can help on a moments notice via Skype: shailpatel05 Thanks.
-
Hello, Trying to update a Magento CE 1.3.2.4 to 1.4. I've read multiple guides and have tried a few different ways but nothing happens. I'm trying it locally on my Mac with MAMP set up. I've installed a 1.4.2 and tried changing the local.xml to point to a copy of the online database but it crashes and i get a blank page. I've also tried installing a 1.4.2 and giving it the online db copy at install and it doesn't go past the db hookup screen. From what I've read, the database type changed from 1.3 to 1.4. I've also tried updating the database with Magento's database repair tool but to no avail. Any thoughts? What i basically want to do is have a brand new 1.8 installation with all the data from the old site. I don't care much if it looks off because we'll be theming it anew so that is of little concern, what's most important is to keep the products/media/clients/orders etc. Thanks for any help!!!
-
Daily WALKIN... PROVAB is Hiring @ Bangalore... PHP Developers with PHP5/ Codeigniter/ Zend/ Magento/ CakePHP/ Opencart/ Prestashop (1.6 to 8Yrs)... 40 Positions... Education- Any, Please refer friends... Ramesh, 080-40593555, +91-8050006446 ramesh.provab@gmail.com PROVAB, NG Complex, 30th Cross Road, Jayanagar 4th T Block, Tilak Nagar, Bangalore
- 1 reply
-
- php
- codeigniter
-
(and 3 more)
Tagged with:
-
I was looking for a magento application for a ecommerce store and finally found a native application called Magento Android Application by Adodis at Android Market place. If you have any other application similar to this please let me know
-
hi all, can anybody please tell me how to add css and js file in head part in magento??? i am using base/template. please need help!!! thanks and regards, jazz
-
Hi, I am not very good at PHP however I am trying to edit a php function for Magento. $categoryID = $this->getCategoryId(); //the value is like 7,3,6,9 $cats = explode(',', $categoryID); $collection = Mage::getModel('catalog/product') ->getCollection() ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left') ->addAttributeToSelect('*') ->addAttributeToFilter('category_id', array( array('finset' => '7'), array('finset' => '3'), array('finset' => '6'), array('finset' => '9') ) ); I want to generate the below part automatically based on the value(s) of $cats array('finset' => '7'), array('finset' => '3'), array('finset' => '6'), array('finset' => '9') How can I do it, urgent help will be extremely appreciated. Thanks in advance
-
We keep having random 500 Internal Server Errors on several of our PHP, MySQL, Magento based sites. I’ve spent hours trying to hunt down what’s happening. Where can I find a php, mysql, magento expert to help me resolve this for good? (Also, our host says our PHP-FPM process continues to segfault. If you know what that means.)
-
Hi, I need help in K-Net integration with Magento. K-Net didn’t give the code in PHP, can anybody help me in integrating K-Net with Magento. If anyone have integrated the K-Net with Magento, please give me steps of how to start in Magento for integration with K-Net. What are the necessary things need to take care. Give me any code / script example on what need to pass in php java brige from magento and how. If anyone have any document, that will help me a lot. Please help me. Thanks Veeneet Kumar
-
So I'm trying to write a script that will reset some values in a Magento product database, but I'm having some issues. I need to code to run for all products, in all stores, for all th attributes. I wrote the inital little script, and it works fine: $product_id = 1657; $store_id = 4; $attr = 'name'; $product = Mage::getModel('catalog/product') ->load($product_id) ->setStoreId($store_id) ->setData($attr, false) ->save(); The issue is, I need it to run for all products, all stores, all attributes. My next step was to test it with one attribute, one store, all products, and my code was: $product_ids = Mage::getModel('catalog/product')->getCollection()->getAllIds(); $store_id = 4; $attr = 'name'; foreach ($product_ids as $product_id){ $product = Mage::getModel('catalog/product') ->load($product_id) ->setStoreId($store_id) ->setData($attr, false) ->save(); } That code gets me no results. If I run the foreach loop and print_r the $product_ids the array contains what I think it should. Anyone have any ideas? I haven't even started to touch the multiple attributes in multiple stores since this doesn't work yet.
-
I've been trying to append an element to the bottom of another using jquery; however, it does not work. Here is my code: <?php $currentPath = $this->getCurrentPath(); $currentCategory = Mage::registry('current_category'); ?> <script type="text/Javascript"> jQuery(document).ready(function(){ $(".childnav").appendTo(".catalognav"); }); </script> <ul class="catalognav"> <?php foreach ($this->getCategories() as $category): ?> <li> <a<?php if ($currentCategory->getId() == $category->getId()): ?> class="selected" <?php endif ?> href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a> </li> <li><span>/</span></li> <?php if ($currentCategory->getId() == $category->getId() || in_array($category->getId(), $currentPath)): ?> <ul class="childnav"> <?php foreach ($this->getSubcategories($category->getId()) as $subcategory): ?> <li><a<?php if ($currentCategory->getId() == $subcategory->getId()): ?> class="selected" <?php endif ?> href="<?php echo $subcategory->getUrl() ?>"><?php echo $subcategory->getName() ?></a></li> <li><span>/</span></li> <?php endforeach ?> </ul> <?php endif ?> <?php endforeach ?> </ul> Basically nothing happens. What I get is this: <ul class="catalognav"> <li> <a class="selected" href="#">Tops /</a> </li> <ul class="childnav"> <li><a href="#">Shirts /</a></li> <li><a href="#">Sweaters /</a></li> <li><a href="#">Tees /</a></li> <li><a href="#">Hoodies and Sweatshirts /</a></li> </ul> <li> <a href="#">Denim /</a> </li> <li> <a href="#">Outerwear /</a> </li> </ul> What I want is: <ul class="catalognav"> <li> <a class="selected" href="#">Tops /</a> </li> <li> <a href="#">Denim /</a> </li> <li> <a href="#">Outerwear /</a> </li> <ul class="childnav"> <li><a href="#">Shirts /</a></li> <li><a href="#">Sweaters /</a></li> <li><a href="#">Tees /</a></li> <li><a href="#">Hoodies and Sweatshirts /</a></li> </ul> </ul> Hopefully that made sense. Thanks for any help in advanced!
-
Hi all, I have building a custom template for a client and have a problem where the price is displaying in the format $19.9500 The code i am using to call the price is: <?php echo $this->helper('catalog/output')->productAttribute($_product, $_product->getPrice(), 'price') ?>