Year: 2015

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); ?>

MY PROJET

check etiquette perdu script

$p_simple = DB::table('product_simple')->get(); foreach ($p_simple as $s) { $sku = $s->sku; $etiquette = $s->etiquette; $update_p = (array)DB::table('db_update')->where('sku', $s->sku)->get(); $new_label = ""; $new_label_arr = explode(',', $etiquette); $lost_label = array(); $exit_label=array(); foreach ($update_p as $u) { if ($u->qty === null && $u->etiquette...

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));