Category: magento

magento

use zend adapter conncet exterme DB

$db = new Zend_Db_Adapter_Pdo_Mysql(array( 'host' => '174.142.90.89', 'username' => 'devleero_app', 'password' => 'app123', 'dbname' => 'devleero_vu_centerdata', 'profiler' => true, )); $profiler = $db->getProfiler(); $sql='select * from product_simple'; $data=$result = $db->fetchAssoc($sql);; $i=0; foreach($data as $d) { var_dump($d); $i++; } echo 'total:'.$i;

magento

detect ip for switch website or websotre

<?php $client_ip=$_SERVER; $json=file_get_contents("http://ipinfo.io/{$client_ip}/json"); $details = json_decode($json); var_dump($details->country); $country=$details->country; switch ($country) { case "CA": case "MX": case "US": $_SERVER = "usd"; $_SERVER = "website"; break; default: $_SERVER = "row"; $_SERVER = "store"; } Mage::run($_SERVER, $_SERVER); ?>

magento

get Module url

Parameter 1 - $routePath The route path follows the Zend behaviour of “module/controller/action”. The module part is self-explanatory. For example “cms” resolves to Mage_Cms. The controller is the class that will handle the address. “cms/page” refers to the class Mage_Cms_PageController....

magento

add image to mangento

$product->addImageToMediaGallery('ABSOLUTE_PATH','image',true,false); select all This snippet will add an image residing in ABSOLUTE_PATH to product, assign it to “image” attribute, move it from original location (true), and uncheck the “Exclude” option (false). Here’s Magento documentation on the method: void addImageToMediaGallery (string...

magento

send email base

$mail = Mage::getModel('core/email'); $mail->setToName('wang'); $mail->setToEmail('xiaoming@leeroy.ca'); $mail->setBody('Mail Text / Mail Content'); $mail->setSubject('test email magento'); $mail->setFromEmail('xiaoming@leeroy.ca'); $mail->setFromName("wangxiaoming"); $mail->setType('html');// YOu can use Html or text as Mail format $mail->send();

magento

send Magento email by templatee

$templateId = "Fav Email"; $emailTemplate = Mage::getModel('core/email_template')->loadByCode($templateId); $userName='wang'; $productName="test 123"; $receiveEmail='xiaoming@leeroy.ca'; $receiveName=$userName; $vars = array('user_name' => $userName, 'product_name' => $productName,'message'=>'test message'); $emailTemplate->getProcessedTemplate($vars); var_dump($emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email', 1))); $emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/name', 1)); var_dump($emailTemplate->send($receiveEmail,$receiveName, $vars));