We can enable the log in Magento. We need to follow the below steps to enable the log.
Login into the Admin panel
Select System -> Configuration
Select Developer tab from left hand side of the page
In that, select Log Settings tab
Enable - Yes and click on Save Config
Header Ad
Tuesday, April 27, 2010
How to resize an image in JAVA or Thumbnail creation in Java
package com.jiva.bean.javabeans;
import java.awt.Image;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import javax.swing.ImageIcon;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import java.awt.Container;
import java.awt.MediaTracker;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.io.BufferedOutputStream;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
public class ImageResize
{
int setWidth;
int setHeight;
com.jiva.application.auth.AppSession appSession;
public void setWidth(int width)
{
setWidth=width;
}
public void setHeight(int height)
{
setHeight=height;
}
public String imageProps(String path) throws FileNotFoundException, IOException
{
File source=new File(path);
Image inImage = new ImageIcon(source.getAbsolutePath()).getImage();
int imageWidth=inImage.getWidth(null);
int imageHeight=inImage.getHeight(null);
inImage.flush();
int returnImageWidth=setWidth;
int returnImageHeight=setHeight;
double ReturnImageRatio = (double)returnImageWidth/ (double)returnImageHeight;
double ImageRatio = (double)imageWidth / (double)imageHeight;
if (ReturnImageRatio < ImageRatio)
{
returnImageHeight = (int)((double)returnImageWidth / ImageRatio);
}
else
{
returnImageWidth = (int)((double)returnImageHeight * ImageRatio);
}
String x=Integer.toString(returnImageWidth)+"."+Integer.toString(returnImageHeight);
return x;
}
public void createThumbnail(String imgFilePath,String thumbPath,int thumbWidth,int thumbHeight)throws Exception{
Image image = Toolkit.getDefaultToolkit().getImage(imgFilePath);
MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(image, 0);
mediaTracker.waitForID(0);
double thumbRatio = (double)thumbWidth / (double)thumbHeight;
int imageWidth = image.getWidth(null);
int imageHeight = image.getHeight(null);
double imageRatio = (double)imageWidth / (double)imageHeight;
if (thumbRatio < imageRatio) {
thumbHeight = (int)(thumbWidth / imageRatio);
} else {
thumbWidth = (int)(thumbHeight * imageRatio);
}
BufferedImage thumbImage = new BufferedImage(thumbWidth,
thumbHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = thumbImage.createGraphics();
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(thumbPath));
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.
getDefaultJPEGEncodeParam(thumbImage);
int quality = 100;
param.setQuality((float)quality / 100.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(thumbImage);
out.close();
}
public static void main(String args[])
{
try{
ImageResize resize=new ImageResize();
resize.createThumbnail("D:/Photos/1/original.jpg", "D:/Photos/1/original_resize.jpg", 70, 70);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
import java.awt.Image;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import javax.swing.ImageIcon;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import java.awt.Container;
import java.awt.MediaTracker;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.io.BufferedOutputStream;
import com.sun.image.codec.jpeg.JPEGEncodeParam;
public class ImageResize
{
int setWidth;
int setHeight;
com.jiva.application.auth.AppSession appSession;
public void setWidth(int width)
{
setWidth=width;
}
public void setHeight(int height)
{
setHeight=height;
}
public String imageProps(String path) throws FileNotFoundException, IOException
{
File source=new File(path);
Image inImage = new ImageIcon(source.getAbsolutePath()).getImage();
int imageWidth=inImage.getWidth(null);
int imageHeight=inImage.getHeight(null);
inImage.flush();
int returnImageWidth=setWidth;
int returnImageHeight=setHeight;
double ReturnImageRatio = (double)returnImageWidth/ (double)returnImageHeight;
double ImageRatio = (double)imageWidth / (double)imageHeight;
if (ReturnImageRatio < ImageRatio)
{
returnImageHeight = (int)((double)returnImageWidth / ImageRatio);
}
else
{
returnImageWidth = (int)((double)returnImageHeight * ImageRatio);
}
String x=Integer.toString(returnImageWidth)+"."+Integer.toString(returnImageHeight);
return x;
}
public void createThumbnail(String imgFilePath,String thumbPath,int thumbWidth,int thumbHeight)throws Exception{
Image image = Toolkit.getDefaultToolkit().getImage(imgFilePath);
MediaTracker mediaTracker = new MediaTracker(new Container());
mediaTracker.addImage(image, 0);
mediaTracker.waitForID(0);
double thumbRatio = (double)thumbWidth / (double)thumbHeight;
int imageWidth = image.getWidth(null);
int imageHeight = image.getHeight(null);
double imageRatio = (double)imageWidth / (double)imageHeight;
if (thumbRatio < imageRatio) {
thumbHeight = (int)(thumbWidth / imageRatio);
} else {
thumbWidth = (int)(thumbHeight * imageRatio);
}
BufferedImage thumbImage = new BufferedImage(thumbWidth,
thumbHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = thumbImage.createGraphics();
graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null);
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(thumbPath));
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
JPEGEncodeParam param = encoder.
getDefaultJPEGEncodeParam(thumbImage);
int quality = 100;
param.setQuality((float)quality / 100.0f, false);
encoder.setJPEGEncodeParam(param);
encoder.encode(thumbImage);
out.close();
}
public static void main(String args[])
{
try{
ImageResize resize=new ImageResize();
resize.createThumbnail("D:/Photos/1/original.jpg", "D:/Photos/1/original_resize.jpg", 70, 70);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Random Password Generation in Java
The following program will generate the random password.
import java.util.Random;
public class AutoPwdGenerator {
public String gen8DigitPwd()
{
String strPassword="";
try{
Random randomPassword = new Random();
int i=randomPassword.nextInt(10);
int j = randomPassword.nextInt(100);
int k = randomPassword.nextInt(100);
int l = randomPassword.nextInt(10);
int m = randomPassword.nextInt(10);
strPassword=i+"T"+j+k+"P"+l;
System.out.println("Auto generated password"+strPassword);
}catch(Exception e)
{
e.printStackTrace();
}
return strPassword;
}
}
public class AutoPwdGeneratorTest
{
public static void main(String args[])
{
AutoPwdGenerator autoGen = new AutoPwdGenerator();
String randomPwd = autoGen.gen8DigitPwd();
System.out.println("Generated Random Password:"+randomPwd);
}
}
import java.util.Random;
public class AutoPwdGenerator {
public String gen8DigitPwd()
{
String strPassword="";
try{
Random randomPassword = new Random();
int i=randomPassword.nextInt(10);
int j = randomPassword.nextInt(100);
int k = randomPassword.nextInt(100);
int l = randomPassword.nextInt(10);
int m = randomPassword.nextInt(10);
strPassword=i+"T"+j+k+"P"+l;
System.out.println("Auto generated password"+strPassword);
}catch(Exception e)
{
e.printStackTrace();
}
return strPassword;
}
}
public class AutoPwdGeneratorTest
{
public static void main(String args[])
{
AutoPwdGenerator autoGen = new AutoPwdGenerator();
String randomPwd = autoGen.gen8DigitPwd();
System.out.println("Generated Random Password:"+randomPwd);
}
}
Monday, April 26, 2010
How to change Pdf logo in Magento
Login into the Magento admin panel
Select System -> Configuration -> Sales
In that select the Invoice and Packing Slip Design. In that upload the logo images.
Select System -> Configuration -> Sales
In that select the Invoice and Packing Slip Design. In that upload the logo images.
how to change pdf font & styles in magento
All the Pdf which are related to the order is available in the following location.
/app/code/local/Mage/Sales/Model/Order/Pdf/
We can edit the invoice pdf font & styles in magento. Please follow the below inorder to successed the changes.
Page format: The default invoice PDF is set up in the A4 format. To set it for letter in /app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php
change
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
to
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
/app/code/local/Mage/Sales/Model/Order/Pdf/
We can edit the invoice pdf font & styles in magento. Please follow the below inorder to successed the changes.
Page format: The default invoice PDF is set up in the A4 format. To set it for letter in /app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php
change
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
to
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_LETTER);
Friday, April 23, 2010
Java Script Regular Expressions
The following are the some of the java script regular expressions.
var Integer =/^[\-]?\d*$/;
var PositiveInteger =/^\d*$/;
var RealNumber = /^[\-]?\d*$|^[\-]?\d*\.\d*$/;
var PositiveRealNumber = /^\d*$|^\d*\.\d*$/;
var Currency = /^[\-]?[\$]?[\-]?\d+$|^[\-]?[\$]?[\-]?\d+\.\d*$|^[\-]?[\$]?[\-]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var Currency$ = /^[\-]?[\$]?[\-]?\d*$|^[\-]?[\$]?[\-]?\d*\.\d*$|^[\-]?[\$]?[\-]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var PositiveCurrency = /^[\$]?\d*$|^[\$]?\d*\.\d*$|^[\$]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var PositiveCurrency$ = /^[\$]?\d*$|^[\$]?\d*\.\d*$|^[\$]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var GeneralNumber = /^\d*$|^\d*\.\d*$/;
var FixedNumber = /^\d*\.\d*$/;
var StandardNumber = /^\d{1,3}(,\d{3})*\.\d{2}$/;
var Percentage = /^\d*$|\d{1,3}(,\d{3})*\.\d{1,3}[\%]?/;
var Alphabet = /^\b[a-z\s\.]*$/i
var Address = /./
var CreditCardNo = /^[0-9]{16}$/;
var AlphaNumeric = /^[a-z_0-9\s]*$/i
var Phone = /^\d{10}$|^\d{3}\-\d{3}\-\d{4}$/;
var LongPhoneFormat = /^\d{10}$|^[\(]?\d{3}[\)]?[\-\s]*\d{3}[\-\s]?\d{4}$/;
var StandardPhoneFormat = /^\d{10}$|^\d{3}[\-\s]{1,2}\d{3}[\-\s]?\d{4}$/;
var ZipCode1 = /^[0-9]{5}$/;
var ZipCode2 = /^[0-9]{4}$/;
var Email = /^[a-z_0-9]?[a-z_0-9\.\-\']+@[a-z_0-9\.\-]+\.[a-z_0-9]{2,3}$/i
var MultiEmail =/^[a-z_0-9\@\.\,\;\:\#\']$/i
var SSN = /^\d{3}[\-\s]*\d{2}[\-\s]*\d{4}$/;
var DateOfBirth=/^\d{2}[\\\s]*\d{2}[\\\s]*\d{4}$/;
var urlPattern = /^(?:(?:ftp|https?):\/\/)?(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z])\b(?:\d+)?(?:\/[^<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^<>()\[\]{}\s\x7f-\xff]+)*)?/;
var Integer =/^[\-]?\d*$/;
var PositiveInteger =/^\d*$/;
var RealNumber = /^[\-]?\d*$|^[\-]?\d*\.\d*$/;
var PositiveRealNumber = /^\d*$|^\d*\.\d*$/;
var Currency = /^[\-]?[\$]?[\-]?\d+$|^[\-]?[\$]?[\-]?\d+\.\d*$|^[\-]?[\$]?[\-]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var Currency$ = /^[\-]?[\$]?[\-]?\d*$|^[\-]?[\$]?[\-]?\d*\.\d*$|^[\-]?[\$]?[\-]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var PositiveCurrency = /^[\$]?\d*$|^[\$]?\d*\.\d*$|^[\$]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var PositiveCurrency$ = /^[\$]?\d*$|^[\$]?\d*\.\d*$|^[\$]?\d{1,3}(,\d{3})*\.\d{0,2}$/;
var GeneralNumber = /^\d*$|^\d*\.\d*$/;
var FixedNumber = /^\d*\.\d*$/;
var StandardNumber = /^\d{1,3}(,\d{3})*\.\d{2}$/;
var Percentage = /^\d*$|\d{1,3}(,\d{3})*\.\d{1,3}[\%]?/;
var Alphabet = /^\b[a-z\s\.]*$/i
var Address = /./
var CreditCardNo = /^[0-9]{16}$/;
var AlphaNumeric = /^[a-z_0-9\s]*$/i
var Phone = /^\d{10}$|^\d{3}\-\d{3}\-\d{4}$/;
var LongPhoneFormat = /^\d{10}$|^[\(]?\d{3}[\)]?[\-\s]*\d{3}[\-\s]?\d{4}$/;
var StandardPhoneFormat = /^\d{10}$|^\d{3}[\-\s]{1,2}\d{3}[\-\s]?\d{4}$/;
var ZipCode1 = /^[0-9]{5}$/;
var ZipCode2 = /^[0-9]{4}$/;
var Email = /^[a-z_0-9]?[a-z_0-9\.\-\']+@[a-z_0-9\.\-]+\.[a-z_0-9]{2,3}$/i
var MultiEmail =/^[a-z_0-9\@\.\,\;\:\#\']$/i
var SSN = /^\d{3}[\-\s]*\d{2}[\-\s]*\d{4}$/;
var DateOfBirth=/^\d{2}[\\\s]*\d{2}[\\\s]*\d{4}$/;
var urlPattern = /^(?:(?:ftp|https?):\/\/)?(?:[a-z0-9](?:[-a-z0-9]*[a-z0-9])?\.)+(?:com|edu|biz|org|gov|int|info|mil|net|name|museum|coop|aero|[a-z][a-z])\b(?:\d+)?(?:\/[^<>()\[\]{}\s\x7f-\xff]*(?:[.,?]+[^<>()\[\]{}\s\x7f-\xff]+)*)?/;
Wednesday, April 21, 2010
Ability to retrieve products under a brand or manufacturer in MAGENTO
$brandId = "1"; //manufacturer id or brand id
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToFilter('manufacturer', array('in' => array($brandId)));
$products->addAttributeToFilter('status', '1');
$products->addAttributeToSelect('*');
$products->load();
echo "";
$products = Mage::getModel('catalog/product')->getCollection();
$products->addAttributeToFilter('manufacturer', array('in' => array($brandId)));
$products->addAttributeToFilter('status', '1');
$products->addAttributeToSelect('*');
$products->load();
echo "";
foreach($products as $product)
echo $product->getId()."
";
Thursday, April 15, 2010
Unable to login into admin panel of MAGENTO.
We can overcome this problem by modifying or updating the following page.
app\code\core\Mage\Core\Model\Session\Abstract\varien.php
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
Comment the isSecure() and save the file.
Hope from the above changes, magento admin will work now on your localhost with the following url.
app\code\core\Mage\Core\Model\Session\Abstract\varien.php
$this->getCookie()->getDomain(),
$this->getCookie()->isSecure(),
$this->getCookie()->getHttponly()
Comment the isSecure() and save the file.
Hope from the above changes, magento admin will work now on your localhost with the following url.
Labels:
Admin panel,
login,
Login in Magento,
Magento,
Magento admin panel
Monday, April 12, 2010
How to get product data using product id in MAGENTO
We can use the following code to get the product data using product id.
$_product = new Mage_Catalog_Model_Product();
$product_id = 535;//define the product id which you required
$_product->load($product_id);
From the above step, all the product data will be loaded in the $_product Product object. Use the following code to print the total data.
echo "
";
print_r($_product->getData());
How to enable USPS in magento
Aside from the many unanswered questions about USPS shipping, I found ONE real gem with all kinds of reasons why USPS shipping might not work:
http://www.magentocommerce.com/boards/viewthread/10356/
1) First you register at usps.com
2) They'll email you a testing server, assuming that you are a developer. IGNORE everything about TESTING, but not the user name:
Thank you for registering for the U. S. Postal Service's Web Tools Application Program Interfaces (APIs). We are providing you with a User ID that serves multiple purposes, as explained below.
Your Username is xxxx
Your Password is xxxx
Your Web Tools User ID, shown above, is required to test and integrate USPS Web Tools APIs. With this ID, you may begin sending calls to the test server. Depending on the API, the address to the test server is either http://testing.shippingapis.com/ShippingAPITest.dll or https://secure.shippingapis.com/ShippingAPITest.dll. Use this information in combination with your User ID and your XML string to send a request to the USPS servers. For more details, refer to the programming guides (located at http://www.usps.com/webtools) for the specific API you are integrating.
A sample test request would look like: "http://testing.shippingapis.com/ShippingAPITest.dll?API=[API_Name]&XML=[XML_String_containing_User_ID]"
...
3) Unless you do want to develop something, immediately let them know that you're using Magento.
4) They'll email the REAL server
5) Then you might just add the server to the shipping setup at ...index.php/admin/system_config/edit/section/carriers/ as I did.
I just tested it and it didn't work. So I went back to the Magento thread and looking at a screenshot there, I noticed that I hadn't entered my user ID. It's been so long, I forgot what it was and I looked it up in my notes.
It STILL didn't work.
FINALLY I realized as I went through their emails that my user ID is NOT what I used to set up my online web tools account at USPS, they had sent a separate user id and pw. I'd forgotten about that and didn't put it in my notes.
So with the RIGHT user id it finally works.
http://www.magentocommerce.com/boards/viewthread/10356/
1) First you register at usps.com
2) They'll email you a testing server, assuming that you are a developer. IGNORE everything about TESTING, but not the user name:
Thank you for registering for the U. S. Postal Service's Web Tools Application Program Interfaces (APIs). We are providing you with a User ID that serves multiple purposes, as explained below.
Your Username is xxxx
Your Password is xxxx
Your Web Tools User ID, shown above, is required to test and integrate USPS Web Tools APIs. With this ID, you may begin sending calls to the test server. Depending on the API, the address to the test server is either http://testing.shippingapis.com/ShippingAPITest.dll or https://secure.shippingapis.com/ShippingAPITest.dll. Use this information in combination with your User ID and your XML string to send a request to the USPS servers. For more details, refer to the programming guides (located at http://www.usps.com/webtools) for the specific API you are integrating.
A sample test request would look like: "http://testing.shippingapis.com/ShippingAPITest.dll?API=[API_Name]&XML=[XML_String_containing_User_ID]"
...
3) Unless you do want to develop something, immediately let them know that you're using Magento.
4) They'll email the REAL server
5) Then you might just add the server to the shipping setup at ...index.php/admin/system_config/edit/section/carriers/ as I did.
I just tested it and it didn't work. So I went back to the Magento thread and looking at a screenshot there, I noticed that I hadn't entered my user ID. It's been so long, I forgot what it was and I looked it up in my notes.
It STILL didn't work.
FINALLY I realized as I went through their emails that my user ID is NOT what I used to set up my online web tools account at USPS, they had sent a separate user id and pw. I'd forgotten about that and didn't put it in my notes.
So with the RIGHT user id it finally works.
Wednesday, April 7, 2010
Newsletter queue not sending in Magento
You can create a cron job to run repeatedly… or manually run them by entering this
http://www.youdomain.com/admin/newsletter_queue/sending
I noticed that when I entered the above, the number of recipients dropped by only about 20 at a time… that’s when I found the second link above. In summary, the system is programmed to send only 20 newsletters at a time! You can change that by changing a line in app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
$countOfSubscritions = 20;
Replace the number 20; with any number you wish. . . and ‘yes’ the code has Subscriptions misspelled throughout - with the ‘p’ missing. I just left it misspelled and increased the number to 200.
Clearly this is not optimal and the newsletter module has some problems with it. For my first newsletter I took the steps listed above. For my second, I decided this took too much time and ended up using a 3rd party program. I’ve used ConstantContact in the past but used CampaignMonitor this time. There is a free extension to link Magento to CampaignMonitor in MagentoConnect. It worked well for me and CampaignMonitor was EXTREMELY easy to use - very clean and concise.
FYI… after I used the CampaignMonitor extension, I had to uninstall it. It seemed to be effecting my ability to save customer profiles on the frontend or backend. Now that I have all of my newsletter subscribers uploaded to CampaignMonitor, I plan on just using their code in my Magento site to allow new subscribers to sign-up and have their subscription stored on CampaignMonitor.
Perhaps someone else might have an easier solution. This was just my solution after hours and hours of frustration with Magento’s newsletter module. You can use Magento for a small list of subscribers. But I’m not sure it is the best option for larger numbers. It is definitely a module that needs some work!
http://www.youdomain.com/admin/newsletter_queue/sending
I noticed that when I entered the above, the number of recipients dropped by only about 20 at a time… that’s when I found the second link above. In summary, the system is programmed to send only 20 newsletters at a time! You can change that by changing a line in app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
$countOfSubscritions = 20;
Replace the number 20; with any number you wish. . . and ‘yes’ the code has Subscriptions misspelled throughout - with the ‘p’ missing. I just left it misspelled and increased the number to 200.
Clearly this is not optimal and the newsletter module has some problems with it. For my first newsletter I took the steps listed above. For my second, I decided this took too much time and ended up using a 3rd party program. I’ve used ConstantContact in the past but used CampaignMonitor this time. There is a free extension to link Magento to CampaignMonitor in MagentoConnect. It worked well for me and CampaignMonitor was EXTREMELY easy to use - very clean and concise.
FYI… after I used the CampaignMonitor extension, I had to uninstall it. It seemed to be effecting my ability to save customer profiles on the frontend or backend. Now that I have all of my newsletter subscribers uploaded to CampaignMonitor, I plan on just using their code in my Magento site to allow new subscribers to sign-up and have their subscription stored on CampaignMonitor.
Perhaps someone else might have an easier solution. This was just my solution after hours and hours of frustration with Magento’s newsletter module. You can use Magento for a small list of subscribers. But I’m not sure it is the best option for larger numbers. It is definitely a module that needs some work!
Monday, April 5, 2010
Changing the Magento Favicon
If you’re using a default theme, the new favicon.ico needs to be uploaded into the /skin/frontend/default/default/favicon.ico directory.
For custom themes, the favicon should go into the /skin/frontend/default/CUSTOM_THEME/favicon.ico directory instead. That was simple and we have successfully updated our favicon! To view it we need to clear the browser cookies and cache and hit refresh.
For custom themes, the favicon should go into the /skin/frontend/default/CUSTOM_THEME/favicon.ico directory instead. That was simple and we have successfully updated our favicon! To view it we need to clear the browser cookies and cache and hit refresh.
Replacing the Logo Image in Transactional Emails of Magento
One important thing to note is that in the root directory, Magento has two main directories for the overall store theme, the /app and /skin directories. The /app directory contains the layout, translations for labels and terms, and templates. On the other hand, the /skin directory contains the graphical elements which are images, style sheets (CSS), and JavaScript for the blocks.
In this article, we will be using the default Magento theme. Therefore, the images we will be using will be located in the directory /skin/frontend/default/default/images. The image below shows the default logo image in the transactional email.
To replace the logo image, upload the new logo image into the images directory and rename the file as logo_email.gif, overwriting the existing image. Also, and very importantly, to ensure that the new image will show up in the transactional emails, the permissions need to be changed so that it includes read and write permissions.
In this article, we will be using the default Magento theme. Therefore, the images we will be using will be located in the directory /skin/frontend/default/default/images. The image below shows the default logo image in the transactional email.
To replace the logo image, upload the new logo image into the images directory and rename the file as logo_email.gif, overwriting the existing image. Also, and very importantly, to ensure that the new image will show up in the transactional emails, the permissions need to be changed so that it includes read and write permissions.
Saturday, April 3, 2010
Ability to get error messages in Magento
The following code will be helpful to get error messages in magento.
$mm = Mage::getSingleton('checkout/session');
foreach ($mm->getData('messages')->getErrors() as $item){
echo $item->getCode();
}
$mm = Mage::getSingleton('checkout/session');
foreach ($mm->getData('messages')->getErrors() as $item){
echo $item->getCode();
}
Ability to get success message in Magento
The following code will be helpful to get the messages in magento.
$mm = Mage::getSingleton('checkout/session');
foreach ($mm->getData('messages')->getItems() as $item){
echo $item->getCode();
}
$mm = Mage::getSingleton('checkout/session');
foreach ($mm->getData('messages')->getItems() as $item){
echo $item->getCode();
}
Friday, April 2, 2010
Retriving Cart Amount in Magento
The following code will be helpful to get the cart totals informaiton in magento.
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
umask(0);
Mage::app();
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('checkout/session');
$totals = $session->getQuote()->getTotals();
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
umask(0);
Mage::app();
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('checkout/session');
$totals = $session->getQuote()->getTotals();
Retriving Cart Items in Magento
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
umask(0);
Mage::app();
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('checkout/session');
$output = "";
foreach ($session->getQuote()->getAllItems() as $item) {
$output .= $item->getSku() . "
";
$output .= $item->getName() . "
";
$output .= $item->getDescription() . "
";
$output .= $item->getQty() . "
";
$output .= $item->getBaseCalculationPrice() . "
";
$output .= "
";
}
print $output;
require_once $mageFilename;
umask(0);
Mage::app();
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('checkout/session');
$output = "";
foreach ($session->getQuote()->getAllItems() as $item) {
$output .= $item->getSku() . "
";
$output .= $item->getName() . "
";
$output .= $item->getDescription() . "
";
$output .= $item->getQty() . "
";
$output .= $item->getBaseCalculationPrice() . "
";
$output .= "
";
}
print $output;
Thursday, April 1, 2010
Magento Vendor Notification
Hi,
This is one of the link which i came across in MAGENTO for vendor notification. This mighe be useful for somebody.
http://www.magentocommerce.com/extension/1193/vendor-notifications
This is one of the link which i came across in MAGENTO for vendor notification. This mighe be useful for somebody.
http://www.magentocommerce.com/extension/1193/vendor-notifications
How to get sub category id's under a category in Magento
The following code will provide the necessary steps for fetching the sub-category id's under selected category.
//this will return the category object
$_category = Mage::getModel('catalog/category')->load($categoryId);
$subcategoryIds = array();
//This will return the list of category id's under specified category
$subcategoryIds = split(",", $_category->getChildren());
//this will return the category object
$_category = Mage::getModel('catalog/category')->load($categoryId);
$subcategoryIds = array();
//This will return the list of category id's under specified category
$subcategoryIds = split(",", $_category->getChildren());
Ability to get all the manufacurers or brands in Magento
We can use the following code to get the list of manufacturers in MAGENTO.
$product = Mage::getModel('catalog/product');
//Retriving the attribute values for the manufacturer id
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer') // This can be changed to any attribute code
->load(false);
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
//This is an array of manufacturers
$manufacturers = $attribute->getSource()->getAllOptions(false);
$product = Mage::getModel('catalog/product');
//Retriving the attribute values for the manufacturer id
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer') // This can be changed to any attribute code
->load(false);
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
//This is an array of manufacturers
$manufacturers = $attribute->getSource()->getAllOptions(false);
Labels:
Brands in Magento,
Magento,
Manufacturers in Magento
How to remove test orders in Magento
There is an extension for deleting test orders
http://www.magentocommerce.com/extension/reviews/module/873
or see this
http://www.eliasinteractive.com/blog/magento-ecommerce-how-to-reset-all-test-order-information-and-set-unique-prefix-for-orders-invoices-shipments-and-credit-memos
or this one http://inchoo.net/ecommerce/magento/delete-test-orders-in-magento/
http://www.magentocommerce.com/extension/reviews/module/873
or see this
http://www.eliasinteractive.com/blog/magento-ecommerce-how-to-reset-all-test-order-information-and-set-unique-prefix-for-orders-invoices-shipments-and-credit-memos
or this one http://inchoo.net/ecommerce/magento/delete-test-orders-in-magento/
Adding new language in Magento
As anything in Magento adding a new language is something that requires a certain procedure which we will explain right now and for future reference.
Follow these easy steps and enjoy your multilingual site:
* 1. Download the desired translation thru Magento connect via admin.
* 2. Once installed Go to: System -> Manage Stores -> Create store view. Enter the data and save.
* 3. Now go to: Configuration -> Current Configuration Scope (Select your language from the dropdown) and on the right side under “Locale options” choose the desired language.
Follow these easy steps and enjoy your multilingual site:
* 1. Download the desired translation thru Magento connect via admin.
* 2. Once installed Go to: System -> Manage Stores -> Create store view. Enter the data and save.
* 3. Now go to: Configuration -> Current Configuration Scope (Select your language from the dropdown) and on the right side under “Locale options” choose the desired language.
Truncate the test data in Magento
This script will start you over, remember to backup first!
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `sales_order`;
TRUNCATE `sales_order_datetime`;
TRUNCATE `sales_order_decimal`;
TRUNCATE `sales_order_entity`;
TRUNCATE `sales_order_entity_datetime`;
TRUNCATE `sales_order_entity_decimal`;
TRUNCATE `sales_order_entity_int`;
TRUNCATE `sales_order_entity_text`;
TRUNCATE `sales_order_entity_varchar`;
TRUNCATE `sales_order_int`;
TRUNCATE `sales_order_text`;
TRUNCATE `sales_order_varchar`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
-- reset customers
TRUNCATE `customer_address_entity`;
TRUNCATE `customer_address_entity_datetime`;
TRUNCATE `customer_address_entity_decimal`;
TRUNCATE `customer_address_entity_int`;
TRUNCATE `customer_address_entity_text`;
TRUNCATE `customer_address_entity_varchar`;
TRUNCATE `customer_entity`;
TRUNCATE `customer_entity_datetime`;
TRUNCATE `customer_entity_decimal`;
TRUNCATE `customer_entity_int`;
TRUNCATE `customer_entity_text`;
TRUNCATE `customer_entity_varchar`;
TRUNCATE `log_customer`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;
ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `log_customer` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;
-- Reset all ID counters
TRUNCATE `eav_entity_store`;
ALTER TABLE `eav_entity_store` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `sales_order`;
TRUNCATE `sales_order_datetime`;
TRUNCATE `sales_order_decimal`;
TRUNCATE `sales_order_entity`;
TRUNCATE `sales_order_entity_datetime`;
TRUNCATE `sales_order_entity_decimal`;
TRUNCATE `sales_order_entity_int`;
TRUNCATE `sales_order_entity_text`;
TRUNCATE `sales_order_entity_varchar`;
TRUNCATE `sales_order_int`;
TRUNCATE `sales_order_text`;
TRUNCATE `sales_order_varchar`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
-- reset customers
TRUNCATE `customer_address_entity`;
TRUNCATE `customer_address_entity_datetime`;
TRUNCATE `customer_address_entity_decimal`;
TRUNCATE `customer_address_entity_int`;
TRUNCATE `customer_address_entity_text`;
TRUNCATE `customer_address_entity_varchar`;
TRUNCATE `customer_entity`;
TRUNCATE `customer_entity_datetime`;
TRUNCATE `customer_entity_decimal`;
TRUNCATE `customer_entity_int`;
TRUNCATE `customer_entity_text`;
TRUNCATE `customer_entity_varchar`;
TRUNCATE `log_customer`;
TRUNCATE `log_visitor`;
TRUNCATE `log_visitor_info`;
ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `log_customer` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;
-- Reset all ID counters
TRUNCATE `eav_entity_store`;
ALTER TABLE `eav_entity_store` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;
Magento Customer Password Encryption
Magento follows the below steps to encrypt the password. This encypted passowrd will be stored in the database.
Let suppose your password will be "test123". Magento will add auto generated slot variable for this password. Let the auto-generated slot is "BJ".
The following is code for generating the hash.
echo Mage::helper('core')->getHash('test123', 'BJ');
Printed variable is the one stroed in the database.
Let suppose your password will be "test123". Magento will add auto generated slot variable for this password. Let the auto-generated slot is "BJ".
The following is code for generating the hash.
echo Mage::helper('core')->getHash('test123', 'BJ');
Printed variable is the one stroed in the database.
Subscribe to:
Posts (Atom)