About jontas

I like to make things that people find useful.

Magento: Send a email to store owner when a order is placed.

It is not hard to set up a Magento multi store environment so when a order is placed in a store, a owner (one owner per store) gets a order confirmation email.
Doing like this will give a copy of the mail that is sent to the customer, and that might not be nice – but this is quick.

In admin, select the store you wish to enter the email address to, and under system > config > sales > sales e-mail override the site default with the email address you would like for this store.

It is also possible to send copies of shipment notices, credit mails etc (basically all mail that is sent from the store).

[Tested with v1.3.2.4]

Gallery2flickr add pagination buttons at the bottom (of the search results) as well.

Gallery2flickr is a gallery2 plugin that acts as a bridge between gallery2 and flickr.

The search page normally only has the next and previous page buttons as the top (and not at the bottom).
In order to add these buttons to the bottom as well, edit modules\Gallery2Flickr\templates\FlickrSearch.tpl and just before the div with the copyright info, enter the following (or find it earlier in the file).

344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
{if isset($Flickr.pages)}
<div class="gbBlock">
  <h4>
   {if ($Flickr.pages > 0)}
     {g->text text="Results %d - %d of %d, Page %d of %d"
     arg1=$Flickr.pages.start arg2=$Flickr.pages.end
     arg3=$Flickr.pages.total arg4=$form.page arg5=$Flickr.pages.pages}
   {/if}
   {if ($form.page > 1)}
     <input type="submit" class="inputTypeSubmit"
       name="{g->formVar var="form[action][previousPage]"}"
       value="{g->text text="&laquo; Back"}"/>
   {/if}
   {if ($form.page < $Flickr.pages.pages)}
     <input type="submit" class="inputTypeSubmit"
       name="{g->formVar var="form[action][nextPage]"}"
       value="{g->text text="Next &raquo;"}"/>
   {/if}
   <input 
      type="submit" 
      class="inputTypeSubmit"
      name="{g->formVar var="form[action][importpage]"}" value="{g->text text="Import this page"}"/>
   <input 
      type="submit" 
      class="inputTypeSubmit"
      name="{g->formVar var="form[action][importresults]"}" value="{g->text text="Import all results"}"/>
 </h4>
</div>
{/if}

Magento: Problem with the Fontis WYSIWYG editor (FCKeditor) and {{store url=””}}

The problem is that a link like <a href="{{store url=""}}"> gets converted to <a href="{{store url="> and that is a problem (it makes the link much longer and the page seams to be lacking a lot of text.

One solution is to replace the "" (2 ") where the second disappears with ” (2 ‘).

It is probably a very good idea to make this change on all " inside {{ }} to ‘s.

However it is still a good idea to do this change in the code mode of the editor or it will do some of its magic on it.

Apache2 virtualhosts

In order to bind a virtualhost to only one ip (if the server has several) add the ip in the VirtualHost tag, to make it listen on all ips – use *
To make the server respond to several names, use the ServerAlias and ServerAlias supports wildcards.

See the examples below for more.

<VirtualHost 111.22.33.55>
    DocumentRoot /www/subdomain
    ServerName www.sub.domain.tld
    ServerAlias *.sub.domain.tld
    ...
</VirtualHost>

<VirtualHost *>
    DocumentRoot /www/domain
    ServerName www.domain.tld
    ...
</VirtualHost>

500 internal sever error after moving CakePHP

If the CakePHP is run in production mode (debug =0), then it is not possible to move the CakePHP to another folder – after the move the site will simply give an error 500. This is since a number of things are cached in CackePHP and if the app is in production mode, then some of the cache is not checked if it needs to be updated.

So if you intend to move a CakePHP directory that is setup as a production environment, then you will need to turn up debug to at least 1 , load the site – then it can be turned back down again.

Magento: Problem with the Fontis WYSIWYG editor (FCKeditor) and custom database predix

We were having lots of trouble getting the Configuration JavaScript working.
The problem turned out to be that we are having a prefix in our database of magento, and the code was not handling this case.
While setting up views in the db would have been one workaround…

To find out if you are suffering from this issue as well, open the fontis_custom_config.php file in an browser – and if you see mysql errors then there is a problem – and below is a solution that worked for us.

We did some edits to the js/fontis/fckeditor/fontis_custom_config.php file to make it handle database prefixes.
added:

28
29
    $prefix = $xml->global->resources->db->table_prefix;
    $tablename = $prefix . "core_config_data";

And then simply replace all the following instances of ‘core_config_data’ (without ‘s) with ‘” . $tablename .”‘ (again without ‘s) (as for insance)

35
            "SELECT * FROM " . $tablename . " WHERE path = 'fontis_wysiwyg/fckeditor/usecustomtoolbarjs'"));

Magento: Problem with DIBS module

Using the DIBS module (from Magento connect); we had the “slight” problem that if the order was payed using the test visa card (from DIBS 10 steps) viewing the order was not possible.
The page only partially rendered but most of it was not shown.

We “fixed” this by adding two things to app/code/local/Mage/Adminhtml/Block/Sales/Order/View/Tab/Info.php

We figured out the problem lied in the “switch($paytype)” statement in the “function printLogo($paytype)”

We started by editing the “default:” statement to read

$res = 'no image for ' . $paytype;

instead of the old statement of

$res = '<img src="' . $paytype;

was what broke the page rendering as that img tag was not ended.

We also added an extra case for the card that didn’t exist in the old switch:

case 'VISA,V-DK':  {
                $res = '<img alt="" />getSkinUrl('images/dibs/visa.gif') . '" border="0" />';  break;
            }

Magento: Adding tax (Swedish moms for example)

There is 4 momsclasses in Sweden (25%, 12%, 6% and 0%).

Under Sales-Tax-Manage tax zones & rates:

Create one rule per momsclass for Sweden with * as region and * as Zip.

Create one rule for customers.

Create one rules per momsclass for products.

Create one Tax rule for each momsclass.

Make sure that the products in the catalog have tax set (if there are product in the catalog).

Under System-Config-Tax make the appropriate settings. (defines if the prices are including or excluding tax, if tax should be added on shipping or not etc)

DSN 5.0.0 – Service Unavaliable

Ran into this error today on a server. Some mails got through but some was not getting through.

Check that /etc/hosts has a FQDN (fully qualified domain name).

Also check the size of the mails being sent, in my case the issue was that mail was to large for the receiving server thus this error message was produced at the sender.

unqualified host name ([something]) unknow; sleeping for retry

sendmail expects to the machine to have a FQDN (fully qualified domain name).

If it does not have that (type “hostname” to check what name the machine has) sendmail will complain about this and take a loot of extra time trying to find it.

To use a FQDN edit “/etc/hosts” and change [something] to [something.yourdomain.com] and this will go away. Updating “/etc/hostname” at the same time might be a good idea; don’t forget to run “/bin/hostname -F /etc/hostname” after updating /etc/hostname.