Upgrading Magento 1 through the Magento Connect Downloader

If you don’t fancy upgrading Magento 1 through command line, you can upgrade Magneto core using Magento’s in-built Magento Connect Downloader.

  • Load yoursite.com/downloader.
  • Login with a user who has full Magento permissions.
  • Make sure to click the “Clear all sessions after successful install or upgrade” option before proceeding.
  • Click the Check for Upgardes button
  • This will load all the packages with upgrade options beside them.
  • Find the package name Mage_All_Latest
  • In the dropdown choose the most recent version of Mage_All_Latest
  • Use the checkbox beside it to include it in the upgrade
  • Click Commit Changes

If you login and don’t see any packages, this may be due to the way the site was built.

At the top of Magento connect downloader enter magento-core/Mage_All_Latest  in the in put box, this will install all latest MagentoConnect core packages on top of existing files and will allow future upgrades through Magento Connect Downloader.

Upgrading Magento 1 through command line

Alternative: Upgrade Magneto using the Magento Connect Downloader

Upgrading Magento is a must to keep your store in top-top condition, protect your customers and your business.

Upgrading Magento through command line is the easiest way to make sure you are running the latest version of the Magento Software

  • Load the root directory of your Magento store
  • Make sure the “mage” file has the right permissions: chmod 777 mage
  • Then launch Magento set-up: ./mage mage-setup
  • If all goes well you can then pull the latest version of the code source code:
    ./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force

If things didn’t go well with mage-setup you may need to run set som preferences….

  1. Make sure your prefered code is set: ./mage config-set preferred_state stable
  2. Then sync your changes: ./mage sync

You can then try the install command again.

That should do the trick.

 

Spammers: Lee Andrew Meranda

I’ve been getting spammed by a company called The Compensation Specialist. They are a personal injury outfit. I’m not sure how they got my email but I didn’t subscribe and we don’t have an existing relationship, both are required for a UK company to send unsolicited email marketing material.

The rules on electronic mail marketing are in regulation 22. In short, you must not send electronic mail marketing to individuals, unless:

  • they have specifically consented to electronic mail from you; or
  • they are an existing customer who bought (or negotiated to buy) a similar product or service from you in the past, and you gave them a simple way to opt out both when you first collected their details and in every message you have sent.

You must not disguise or conceal your identity, and you must provide a valid contact address so they can opt out or unsubscribe.

I can’t seem to find any online or email contact details so might have to send this post out to him at his registered address.

Edit: Found an email address for one of Lee’s other companies, I’ll email there to find out wasssup.

The link in the spam email directs through to a contact form, which handily includes Mr Meranda’s companies record with the Crisis Management Regulator.

The Claims Regular provides an outline of Lee’s organisations. I’ll see if I can contact him through one of those.

Other trading names include: UK Claim Experts, Accident Compensation Alliance, 60 Second Claim, UK Claim Lawyers, Nationwide Injury Lawyers, Smart Compensation

How to update your hosts file.

Every computer has a file on it which allows the owner to specify where a website is loaded from. A hosts file is a simple combination of domain names and IP addresses.

Adding a record to your hosts file means your computer will load the domain using the IP address specified, rather than the one provided by DNS.

111.222.333.444 www.domain.com
111.222.333.444 domain.com
111.222.333.555 subdomain.domain.com
  1. Press the Windows key.
  2. Type Notepad in the search field.
  3. Right-click on the Notepad result
  4. Select Run as administrator.
  5. From Notepad, open: C:\Windows\System32\Drivers\etc\hosts
  6. Add the new lines to the file.
  7. Click File > Save to save your changes.
  8. Exit Notepad
  1. Open a terminal window.
  2. Open the hosts file in a text editor (you can use any text editor) by typing the following line:
    sudo nano /etc/hosts
  3. Enter your domain user password.
  4. Make the necessary changes to the file.
  5. Save the file
Good luck.

Mac OS X 10.0 through 10.1.5

  1. Open /Applications/Utilities/NetInfo Manager.
  2. To allow editing of the NetInfo database, click the padlock in the lower-left corner of the window.
  3. Enter your domain user password and click OK.
  4. In the second column of the browser view, select the node named machines.

    The third column contains entries for -DHCP-broadcasthost, and localhost.

  5. In the third column, select localhost.
  6. From the Edit menu, select Duplicate. (The quickest way to create a new entry is to duplicate an existing one.)

    A confirmation alert appears.

  7. Click Duplicate.

    A new entry called localhost copy appears, and its properties are shown below the browser view.

  8. Double-click the value of the ip_address property and enter the IP address of the other computer.
  9. Double-click the value of the name property and enter the hostname you want for the other computer.
  10. Click the serves property and select Delete from the Edit menu.
  11. From the File menu, select Save.

    A confirmation alert appears.

  12. Click Update this copy.
  13. Repeat steps 6 through 12 for each additional host entry that you want to add.
  14. From the NetInfo Manager menu, select Quit.

    You do not need to restart the computer.

Mac OS X 10.6 through 10.12

  1. Open Applications > Utilities > Terminal.
  2. Open the hosts file by typing the following line in the terminal window:
    sudo nano /private/etc/hosts
    
  3. Type your domain user password when prompted.
  4. Edit the hosts file.

    The file contains some comments (lines starting with the # symbol), and some default hostname mappings (for example, 127.0.0.1 – local host). Add your new mappings after the default mappings.

  5. Save the hosts file by pressing Control+x and answering y.
  6. Make your changes take effect by flushing the DNS cache with the following command:
    dscacheutil -flushcache

The new mappings should now take effect.

Magento Server Transfer – Tried and Tested Method

Moving an entire Magento site from one server to another or between hosts can be a daunting task for non-server administrators.

I’m going to try and expand this over time.

  • Agree time frames, a day for file system sync, an hour for database update and DNS update.
  • Content Freeze – no new images or content is added by Store owner, customers continue to place orders and create accounts.
    • A copy of the site is downloaded to the new server via FTP
    • A snapshot of the database is taken and used to test the site on the new server
  • Database Freeze – no new orders, holding page on the front end, Admin Panel still accessible if required but no updates allowed.
    • Export/import database
      • Old Server: mysqldump -u YourUser -p YourDatabaseName > wantedsqlfile.sql
      • New Server wget http://www.yourwebsite.com/wantedsqlfile.sql
      • New Server: mysql -u YourUser -p YourDatabaseName < wanted.sql
    • Copy over/configure your SSL for the new site
    • Next-up is the DNS update to repoint the domain
  • Done

 

Ordering assets in Magento 2

This one will come in useful until Magento 2 sorts itself out.

For some reason, Magento 2 has no way to order assets out of the box. There is now an extension which allows you to set an order attribute in the CSS tags of the layout XML files and layout updates in Admin Panel.

Github: Mage2 Ordered Assets by Quickshiftin

Example

Before

<head>
   <css src="css/app.css" />
</head>

After

<head>
   <css src="css/app.css" order="100" />
</head>

PHP: glob

glob($string);

Return an array of pathnames matching a specific pattern.

// Find all CSV files in the /home/var/imports/ directory 
glob("/home/var/imports/hello-*.csv");
  • /home/var/imports/hello-world.csv – Returned
  • /home/var/imports/hell-world.csv – Not returned
  • /home/var/imports/hello-.csv – Returned.

Magento Code: Check an import directory for new product CSVs and process using a Magmi profile

This script will first scan the var/import directory for all CSV files starting “import-” using the glob() function in PHP. It will return an array of any files which match the query in the directory including the file path from root.

The $file_parts will be used later when we need just the file name.

$cmd is the executable shell command we will be using to load Magmi, set the profile, mode and chosen file.

The shell_exec() function runs the command and will return any output to the $output variable, this can be expanded to check for a successful import. The script below will carry on regardless of import status.

Once the import is complete we take the CSV and copy it into an archive folder, just in case we want to reuse it. The original file is then deleted from the var/import folder using unlink()

This script can then either be run manually, or set-up as a scheduled task using Cron.

// Find all CSV files in import directory
$files = glob('/home/admin/public_html/var/import/import*.csv');

// For each of the files found 
foreach ($files as $file):

   // Explode for teh the file name in 6th position of the array
   $file_parts = explode("/",$file);

   // Set-up the command 
   $cmd = 'php /home/admin/public_html/magmi/cli/magmi.cli.php -profile=default -mode=create -CSV:filename="'.$file.'"';

   // Execute the comamnd 
   $output = shell_exec($cmd);

   // Copy the executed script into an archive folder
   if ( copy($file,'/home/admin/public_html/var/import/archive/'.$file_parts[6]) ):
      // Delete the original
      unlink($file);
   endif;

endforeach;

Magento: What are Sage Pay Orphan Transactions?

This is a regular issue when using Sage Pay with Magento that needs a bit of explaining.

Sage Pay transactions started by the customer are stored in the Magento database. When a transaction is completed successfully this Sage Pay transaction is linked to the completed order in Magento.

When a order does not complete this leaves transactions in the Magento database not connected to a Magento order ID. These are orphaned transactions. The cause can be the customer abandoning the order at some point (e.g. the 3D secure checks), a declined/rejected payment, or caused by an error when Magento Saves the order. Because there is no completed Order ID to connect the transaction to these are considered “orphans”.

Orphaned  transactions are not always bad. If you monitor the list of orphaned transactions in Magneto (Sales > Sage Pay > Orphan Transactions) you can use the details to recover lost sales, for example a telephone or email address may be available to contact customers who have been unable to complete 3D Security checks and enter the order manually.

The most important thing to note is that Sage Pay integration will not tell Magento to save an order unless the payment has been successfully taken. The successful payment response from Sage Pay will create the “processing” order in Magento. This stops issues with inventory and shipping unpaid for orders.

The Sage Pay Suite Orphan Transaction list will not only help you spot issues with customers processing orders, it can also help you recover sales.

PHP: header

header($string);

Used to send a raw HTTP header, often used for page redirects.
Must be called before any other output is sent.

// Redirect the request to https://keithgreer.uk
header("Location: https://keithgreer.uk");
// Send an error code to the browser, for example a 404
header("HTTP/1.0 404 Not Found");

PHP: str_replace

str_replace($search,$replace,$subject)

All instances of $search are replaced with $replace in $subject.

// Will print to screen: "Why is the sky blue?". 
echo str_replace("red","blue","Why is the sky red?")

Create a custom URL rewrite/redirect in Magento

You can use a custom rewrite to redirect CMS pages, or any other type of page. For example, if you change the URL key of the privacy policy from privacy-policy-cookie-restriction-mode to privacy-policy, the link in the cookie restriction mode will return “404 – Page Not Found.” To redirect traffic to the new URL key, create a custom rewrite with the following settings:

ID Path: privacy-policy
Request Path: privacy-policy-cookie-restriction-mode
Target Path: privacy-policy
Redirect: Permanent (301)

Before you begin, figure out the URL keys that you need for the ID Path, Request Path, and Target Path. Just remember— the “Request Path” is the old URL, and the “ID Path” and “Target Path” are the new URL.

Magento Code: Include currency switcher in the header or footer with Foundation mark-up

It is easy to set-up multi-currencies in Magento. This code  allows you to quickly include a currency drop down or link to  the header or footer of your Magento store. Before you begin make sure you have enabled more than one currency  as this example won’t work without at least one additional currency alongside your base currency.

Set-up the following code in your theme directory /app/design/frontend/package/theme/template/currency/currency.phtml. I’ve included code for both a drop down select box, or inline list of hyperlinks.

Continue reading Magento Code: Include currency switcher in the header or footer with Foundation mark-up

Magento Code: Add a drop down attribute and display it on the product page in custom HTML

Magento makes it really easy to expand the usual product attributes through the Admin Panel. While these can be added to the product page in the standard attribute list table, you may want your attribute to appear differently or use it for another feature. This post explains how.

In this example we’ll be adding an attribute to tell the customer how long they might have to wait on a product to arrive.

Continue reading Magento Code: Add a drop down attribute and display it on the product page in custom HTML