вторник, 1 октября 2013 г.

Основы работы с Git

 Основы работы с Git

Введение

Git (произн. «гит») — распределённая система управления версиями файлов. Проект был создан Линусом Торвальдсом для управления разработкой ядра Linux. На сегодняшний день поддерживается Джунио Хамано.
Система спроектирована как набор программ, специально разработанных с учётом их использования в скриптах. Это позволяет удобно создавать специализированные системы контроля версий на базе Git или пользовательские интерфейсы. Например, Cogito является именно таким примером фронтенда к репозиториям Git, а StGit использует Git для управления коллекцией патчей.

вторник, 24 сентября 2013 г.

Конфигурация Nginx + PHP + FastCGI для Magento

Не так давно пришлось оптимизировать сервер у заказчика. Нужно было заменить Apache на Nginx. 
На официальном форуме можно найти примеры конфигурации, например
http://www.magentocommerce.com/boards/viewthread/7931/ ,
однако использование rewrite для таких случаев всячески порицается разработчиком сервера.

Замечания

* Процесс сборки nginx и php описан на офсайтах
* Предполагается, что php с поддержкой fast-cgi настроен и работает на
127.0.0.1:8888, а nginx на 127.0.0.1:80
* Папка, в которой лежат файлы Magento: /home/alex/www/server.com/
* Так как Nginx работает с php напрямую, а не через связку с Apache, следует
обратить особое внимание
  на директивы для php, которые идут в .htaccess из стандартной поставки magento. Nginx 
  не обрабатывает директивы из .htaccess и поэтому их нужно перенести в php.ini. 
  У меня, например, перестала работать загрузка картинок к товарам, пока не добавил suhosin.session.cryptua off в php.ini.
* Предполагается, что в Magento настроены ЧПУ

Ниже привожу свою конфигурацию. Дополнения и комментарии всячески приветствуются.

    server {
    listen 127.0.0.1:80;
    server_name server.com;
    #Включаем сжатие
    gzip on;
    #gzip_comp_level 9;
    gzip_min_length 1000;
    gzip_proxied any;
    gzip_types text/plain application/xml text/html text/css text/js application/x-javascript;
    # Важно!!!! Ниже должна быть указана папка в которой лежит код Magento
    root /home/alex/www/server.com/;

    location / {
    index index.php;
    error_page 404 = @magento;
    }
    # Фикс для js
    location /js/ {
    index index.php;
    error_page 404 = @magento_js;
    }
    # Фикс для случая, когда используется расширение FOOMAN_Speedster.
    location ^~ /minify/ {
    rewrite ^/minify/([^/]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
    break;
    }

    location @magento {
    # Если fastcgi_params лежит по другому пути то заменить на свой
    include /etc/nginx/fastcgi_params; #Важно !!!!
    fastcgi_pass 127.0.0.1:8888;
    fastcgi_param SCRIPT_FILENAME $document_root/index.php; #Важно !!!
    }

    location @magento_js {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.1:8888;
    fastcgi_param SCRIPT_FILENAME $document_root/js/index.php;
    }
    location ~ .php$ {
    index index.php;
    include /etc/nginx/fastcgi_params;
    fastcgi_pass 127.0.0.12:8888;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~* \.(jpg|gif|png|css|js|jpeg|ico)$ {
    if (-f $request_filename) {
    access_log off;
    expires 7d;
    }

    }

После такой настройки плагин YSlow дает сайту уровень B по скорости. Если очень постараться и
 вынести всю статику на отдельный поддомен, то можно еще ускориться. 
 
Источник 

Magento + Nginx

This config currently seems to work for the <1 .4="" p="" versions="">
server {
  server_name example.com;
  root /var/www/vhost/example.com/htdocs;
  access_log /var/log/nginx/example.com.access.log main;
  index index.php;
 
  location / {
    try_files $uri $uri/ /index.php?$args; 
  }
 
  # set a nice expire for assets
  location ~* "^.+\.(jpe?g|gif|css|png|js|ico|pdf|zip|tar|t?gz|mp3|wav|swf)$" {
    expires    max;
    add_header Cache-Control public;
  }
 
  # the downloader has its own index.php that needs to be used
  location ~* ^(/downloader|/js|/404|/report)(.*) {
    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$1/index.php$1;
    fastcgi_read_timeout 600;
    fastcgi_pass  127.0.0.1:9000;
  }
 
  location ~* \.php {
    include fastcgi_params;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    fastcgi_read_timeout 600;
    fastcgi_pass  127.0.0.1:9000;
  }
 
}

This config works for version 1.7:
server {
  root    /home/magento/web/;
  index    index.php;
  server_name magento.example.com;
  location / {
    index index.html index.php;
    try_files $uri $uri/ @handler;
    expires 30d;
  }
  location ~ ^/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; }
  location /var/export/ { internal; }
  location /. { return 404; }
  location @handler { rewrite / /index.php; }
  location ~* .php/ { rewrite ^(.*.php)/ $1 last; }
  location ~* .php$ {
    if (!-e $request_filename) { rewrite / /index.php last; }
    expires off;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param MAGE_RUN_CODE default;
    fastcgi_param MAGE_RUN_TYPE store;
    include fastcgi_params;
  }
}

Fooman Speedster is a popular extension that requires editing your server configuration. If you use it add this at the bottom of one of the server configurations above, right before the closing bracket.
 rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
 rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
 
 location /lib/minify/ {
   allow all;
 }

вторник, 28 мая 2013 г.

Magento: Magento 1.3.x, 1.4.x, 1.5.x, 1.6.x and 1.7.x update procedure


This is actually the current explanation from the Magento 1.3.x, 1.4.x, 1.5.x, 1.6.x and 1.7.x  x update procedure.It includes step x step directions as well as repair info.

Get ready for Magento update (for 1.3.x, 1.4.x x variations only)

Allows image resolution you have aged Magento 1.3.x – 1.4.x.x shop and you also have to update this in order to most recent Magento 1.7.x edition.To begin with it really is strongly suggested in order to back-up your own reside shop files/database as well as deactivate Magento compiler cache.
After that you want to get SSH accessibility from the web hosting supplier as well as connect with your own machine through SSH process (using Cpanel control covering or even Putty SSH customer with regard to Windows).
Right after link through SSH, visit your own shop document as well as perform these types of instructions:

1 Modify accord upon lib/pear document in order to writable (recursively):
chmod -R 777 lib/PEAR
2 Perform this particular control to get ready Magento with regard to update:
./pear mage-setup
Almost certainly you guys will discover this particular outcome right after control performance: Station “connect.Magento commerce.com/core” has already been initialized

Update through Magento 1.3.x, aged 1.4.x in order to Magento 1.4.2.0

Update in order to 1.4.2.0 is needed, even though you get some new aged Magento 1.3.x shop in order to 1.7.x edition.
1 Perform Magento update control:
./pear upgrade -f magento-core/Mage_All_Latest-stable
Outcome from the control will reveal exactly what primary deals had been improved:

upgrade ok: channel://connect.magentocommerce.com/core/Mage_Centinel-1.4.2.0
upgrade ok: channel://connect.magentocommerce.com/core/Interface_Frontend_Base_Default-1.4.2.0
upgrade ok: channel://connect.magentocommerce.com/core/Phoenix_Moneybookers-1.2.3
upgrade ok: channel://connect.magentocommerce.com/core/Find_Feed-1.0.7
upgrade ok: channel://connect.magentocommerce.com/core/Interface_Adminhtml_Default-1.4.2.0

2 Whenever this particular section of the update is going to be total, get into these types of instructions:
chmod 550 ./mage
./mage mage-setup .
People will discover this particular outcome right after control performance:
Effectively additional: http://connect20.magentocommerce.com/community

This means which Magento link 2 .0 station had been put into the actual stations listing effectively.

3 Following, get into this particular control:
./mage sync
The end result is going to be:

Successfully added: community/Mage_Locale_en_US-1.4.2.0
Successfully added: community/Interface_Install_Default-1.4.2.0
Successfully added: community/Phoenix_Moneybookers-1.2.3
Successfully added: community/Mage_Downloader-1.5.0.0
Successfully added: community/Lib_Google_Checkout-1.4.2.0

Update in order to Magento 1.4.2.0 is actually total and today you are able to continue along with update in order to Magento 1.7.x edition.

Update through Magento 1.4.x, 1.5.x, 1.6.x in order to Magento 1.7.x

Right now you guys may update the shop in order to edition 1.7.0.2 .
Prior to going forward with this particular portion of Magento update, it is very important notice as to what edition Magento update intrigue will certainly get some new shop.Get into this particular control to check on this particular:
./mage list-upgrades
In case you will discover this particular outcome:
Updates for community:
Mage_All_Latest: 1.4.2.1 => 1.7.0.2
Lib_Js_Mage: 1.4.2.0 => 1.7.0.2
Lib_Varien: 1.4.2.0 => 1.7.0.2

This means that the Magento is going to be improved in order to edition 1.7.0.2. When it is not really the thing you need you are able to modify update station in order to “beta” as well as get some new Magento in order to RC (beta) edition.

1 Get into this particular control to improve the actual update station in order to stable (remember, “stable” station will certainly get some new Magento in order to most recent 1.7.x stable version):
./mage config-set preferred_state stable
Following this the actual “./mage list-upgrades” control will reveal this particular outcome:
Updates for community:
Mage_All_Latest: 1.4.2.1 => 1.7.0.2.
Lib_Js_Mage: 1.4.2.0 => 1.7.0.2.
Lib_Varien: 1.4.2.0 => 1.7.0.2.
Lib_Phpseclib: 1.4.2.0 => 1.7.0.2.
Mage_Core_Adminhtml: 1.4.2.0 => 1.7.0.2.
Mage_Core_Modules: 1.4.2.0 => 1.7.0.2.

2 Right after station choice you are able to get some new Magento in order to Magento 1.7.0.2) employing this control:
./mage upgrade-all --force
In case “./mage upgrade-all -force” will never function, you can test in order to perform this particular control:
./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force
You will notice improved deals on the display screen:

Package upgraded: community/Mage_Locale_en_US 1.7.0.2
Package upgraded: community/Lib_Mage 1.7.0.2
Package upgraded: community/Lib_ZF 1.11.1.0
Package upgraded: community/Lib_Js_Prototype 1.7.0.2.
Package upgraded: community/Lib_ZF_Locale 1.11.1.0

Right now the actual update is actually total and you may perform data source update going to your own Magento shop within your internet browser, this method will require a number of moments, therefore have patience.In case every thing had been improved properly, you will notice improved shop within your internet browser.Prior to data source update it is strongly recommended to improve some memory space limitations associated with the PHP motor.

When it is impossible to improve this, you can test in order to perform data source update through SSH, electronic. gary the gadget guy.:
php -f ./index.php
Whenever data source update is going to be completed, you should check edition of the shop within the footer associated with Magento management screen.

Repair

1 Magento update software mistake:

upgrade-all: Booking with regard to adequate create document accord.
Mistake: upgrade-all: Your own Magento document don't have adequate create accord, that downloader needs.
Perform this particular control to correct the actual mistake: 
chmod -R 777 Upgrade
2 Magento update software mistake:

upgrade-all: Incorrect balance within compare Stabilities discussion.
Perform these types of instructions, it is going to repair the problem:

./mage channel-add connect20.magentocommerce.com/community
./mage channel-add connect20.magentocommerce.com/core
./mage sync
Or even like a remedy you are able to operate this particular control:
 
./mage install http://connect20.magentocommerce.com/community Mage_All_Latest --force
3 Machine mistake:

“Internal Machine Error” rather than Magento local store web page or even management area webpages.

Almost certainly problem is actually linked to incorrect accord.

Repair this problem using 1 of these recursive instructions:
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
4 Magento mistake: Various mistakes within Magento data source.

Re-index your own data source within Magento management screen as well as crystal clear Magento cache.

5 Magento mistake:

“Invalid way of clean() method”.

Crystal clear Zend cache (all documents, such as “Backend” folder) within [magento_folder]/app/code/core/Zend/Cache/

6 Magento mistake:

“Call to some associate functionality to Html() on the non-object within …/Layout.php”.

Open [magento_folder]/app/design/frontend/default/[your_theme]/layout/page.xml and replace this line of the code:
   
With:
 
7 Magento mistake:

“Maximum crucial dimension should be smaller sized 32″. Crystal clear Magento cache.

8 Pagination is not really displaying upon item real estate:

Open up this particular document: app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php

As well as substitute this particular type of the actual program code
course Mage_Catalog_Block_Product_List_Toolbar stretches Mage_Core_Block_Template
along with:
course Mage_Catalog_Block_Product_List_Toolbar stretches Mage_Page_Block_Html_Pager

9 Magento mistake:

Line not really discovered: 1 054 Not known line ‘custom_use_parent_settings’ within ‘where clause’
Re-index your own data source utilizing Control panel covering.
10 Magento mistake:
Are not able to connect with the actual data source. What is /app/etc/local.xml and ensure there is this kind of program code
{{db_model}}
 
Источник 

четверг, 18 апреля 2013 г.

Using Media Image Product Attributes


Posted on: 12th Sep 2011 By: Adam Moss 9 Comments
This is perhaps a bit of a hidden gem with Magento, because it can be extremely useful when needed. Here’s a scenario: your client wants an image on their product page which is detached from the main image gallery. A solution may be a text field or dropdown attribute, which can be used to enter a URL to the chosen image. This won’t help clients who want to add new images though unless they have sufficient FTP privelages – we all know that this can have similar consequences as letting a bull loose in a china shop, then pricking its ass with a needle.
The solution is a media image attribute, this is how to set one up…

среда, 3 апреля 2013 г.

Magento модуль для импорта нескольких изображений товара

Magento: Import Multiple Images for Products Module

Magento Icon
Update: If you are using Magento 1.5 or higher, please see my Revised Multiple Image Import Module post
I still am confused as to why Magento hasn’t built-in the ability to upload multiple images for each product. After scoping it out, finally, I discovered that the modification was quite simple. I haven’t put the module up on Magento Connect yet (not sure if I will), but here I will lay out how to do it, which for some of you may help you understand how modules work, if you don’t know already.
I’ve seen some solutions out there that modify core code, some that just take a file and move it to your /app/code/local/ retaining the same directory structure, so as to just override the file. I don’t recommend either of these methods (especially the first), as with a true module you are setting up a much better environment over time for this to last. And a module allows you to ONLY override the methods you need to modify, instead of entire classes. Plus, you can easily disable the module right in the admin (Admin >> System >> Configuration >> Advanced).
Be sure you replace all of the “YOURSTUFF” with your name or company name.
I have only tested this with 1.3.2.4

вторник, 2 апреля 2013 г.


How to use Magento Shipping Table Rates

With Magento you can set few kinds of shipping methods: flat rate, table rates or even real-time carrier rates from UPS, FedEx and DHL. You can also use free shipping discounts, that can be created for order amounts, or as part of specific marketing promotions.
To set shipping methods in backoffice go to System -> Configuration and choose from the left navigation "Shipping methods". When you want to use Table rates you can choose one of three conditions avalaible:
  • Weight vs. Destination
  • Price vs. Destination
  • Number of Items vs. Destination


понедельник, 18 марта 2013 г.

mercurial - конфигурация hgrc , чтобы не спрашивал пароля

Что надо написать в файле hgrc, чтобы не спрашивал пароль на bitbucket-е?
Вот в этом файле - <имя_проекта>/.hg/hgrc - я написал следующее



Этот конфигурационный файл я храню в сухом, прохладном, тёмном месте,
недоступном для маленьких детей и домашних животных.

четверг, 28 февраля 2013 г.

Display Categories and SubCategories in Magento

Display Categories and SubCategories in Magento

A newer, better version of this post has been written.
Category Navigation Listings in Magento eCommerce
The majority of Magento websites out there list their top level categories as well as the current categories sub-categories. This feature is commonly requested on forums so I decided to write a small post about it.
Rather than just write out the code, I will show you a few variations so that you can get the right one for you.
All of the following code samples can be copy and pasted into ANY template file and will function correctly.

Display Top Level Categories Only

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * http://fishpig.co.uk - Magento Tutorials
 *
 * Display top level categories
 *
**/
?>
$_helper = Mage::helper('catalog/category') ?>
$_categories = $_helper->getStoreCategories() ?>
if (count($_categories) > 0): ?>
    
            foreach($_categories as $_category): ?>
                
  •                 "getCategoryUrl($_category) ?>">
                        echo $_category->getName() ?>
                    
                
            endforeach; ?>
        
    endif; ?>

    Display Top Level Categories and ALL Subcategories

    ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    /*
     * http://fishpig.co.uk - Magento Tutorials
     *
     * Display top level categories and subcategories
     *
    **/
    ?>
    $_helper = Mage::helper('catalog/category') ?>
    $_categories = $_helper->getStoreCategories() ?>
    $currentCategory = Mage::registry('current_category') ?>
    if (count($_categories) > 0): ?>
        
              foreach($_categories as $_category): ?>
                  
    •                 "getCategoryUrl($_category) ?>">
                          echo $_category->getName() ?>
                      
                      $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                      $_subcategories = $_category->getChildrenCategories() ?>
                      if (count($_subcategories) > 0): ?>
                          
                                foreach($_subcategories as $_subcategory): ?>
                                    
      •                                 "getCategoryUrl($_subcategory) ?>">
                                            echo $_subcategory->getName() ?>
                                        
                                    
                                endforeach; ?>
                            
                        endif; ?>
                    
                endforeach; ?>
            
        endif; ?>

        Display Top Level Categories and Current Categories SubCategories

        ?
        1
        2
        3
        4
        5
        6
        7
        8
        9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        /*
         * http://fishpig.co.uk - Magento Tutorials
         *
         * Display top level categories and
         * subcategories of the current category
         *
        **/
        ?>
        $_helper = Mage::helper('catalog/category') ?>
        $_categories = $_helper->getStoreCategories() ?>
        $currentCategory = Mage::registry('current_category') ?>
        if (count($_categories) > 0): ?>
            
                  foreach($_categories as $_category): ?>
                      
        •                 "getCategoryUrl($_category) ?>">
                              echo $_category->getName() ?>
                          
                          if ($currentCategory && $currentCategory->getId() == $_category->getId()): ?>
                              $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
                              $_subcategories = $_category->getChildrenCategories() ?>
                              if (count($_subcategories) > 0): ?>
                                  
                                        foreach($_subcategories as $_subcategory): ?>
                                            
          •                                     "getCategoryUrl($_subcategory) ?>">
                                                    echo $_subcategory->getName() ?>
                                                
                                            
                                        endforeach; ?>
                                    
                                endif; ?>
                            endif; ?>
                        
                    endforeach; ?>
                
            endif; ?>
             
             

            Magento события и rewrite классов

            Стараясь сделать свою систему максимально гибкой и расширяемой разработчики Magento предусмотрели возможность перезаписи любых классов, при чем аж двумя разными способами. Первый базируется на 3-х скоупах и особенностях автолоадера (назовем его copy-paste), а второй на конфигурации модуля (назовем его extends).

            Magento: Overriding Core Files (Blocks, Models, Resources, Controllers)


            Magento: Overriding Core Files (Blocks, Models, Resources, Controllers)

            Magento Icon
            When building custom modules for Magento, one of the most common needs is to override Magento’s core files, most commonly Blocks, Models, Resources, and Controllers. And, by the way, when I say “override”, that is also synonymous with “rewrite” or “extend”.
            I wanted to write this up for my own reference, but I hope this ends up helping you to. At the time of writing this, all of these methods have been tested on 1.4.0. This post assumes you to have familiarity with writing Magento modules. And remember, you only need to include functions in your file that you are modifying. Leave all untouched functions out of your file.
            Also, the reason I haven’t included much for examples of the actual block/model code is that 90% of getting a rewrite to work correctly is just getting your config.xml correct. It matters way less of where you put your files in your module (though it’s good to keep it organized and clean).

            Overriding Core Blocks

            One of the more simple and straight-forward things to override in Magento. Let’s say that you want to override the following class: Mage_Catalog_Block_Product_View.
            The first step is to copy the file into your own module’s Block folder. It can be anywhere you want within that folder, it really doesn’t matter. But, for organizational purposes, it’s always best, in my opinion, to keep a similar folder/file structure as Magento does. In this case, I would put this file in My/Module/Block/Catalog/Product/View.php. Of course, you’ll need to rename the class, and have it extend Mage_Catalog_Block_Product_View.
            Here is how the ‘blocks’ tag in your config.xml should look:
            >
            > >My_Module_Block> > > > >My_Module_Block_Catalog_Product_View> > > > As you can see, we’ve got the rewrite xml inside of the ‘catalog’ tag. This refers to app/code/core/Mage/Catalog/. Then the ‘rewrite’ tag tells Magento that we are going to override a block (since we are within the ‘blocks’ tag) under Mage/Catalog/. The ‘product_view’ tag points to Mage/Catalog/Block/Product/View.php, and within that tag is the name of the class that we are using to override the core block.
            As another example, if you wanted to override Mage/Catalog/Block/Product/View/Type/Simple.php, the tag under ‘rewrite’ would be ‘product_view_type_simple’.

            Overriding Core Models

            Overriding models (but not resource models, which are anything declared in config.xml as ‘resourceModel’, which are typically files within a Mysql4 directory) is basically the same as blocks (above). So, I will give an example, but leave out much of the explanation.
            Lets say that I want to modify the model for the items on an order invoice (Mage_Sales_Model_Order_Invoice_Item). I will copy that file to My/Module/Model/Sales/Order/Invoice/Item.php, rename the class, and extend Mage_Sales_Model_Order_Invoice_Item.
            The config.xml ‘models’ will look something like this:
            >
            > >My_Module_Model> > > > >My_Module_Block_Sales_Order_Invoice_Item> > > >

            Overriding Core Resource Models

            I found out the hard way once, and wasted a couple hours, that resource models have a different way of overriding them. All of the concepts are the same, with the exception of the syntax in your config.xml file. A resource model is typically going to be models that reside within a ‘Mysql4′ folder. The resource model folder is typically defined in the config.xml file using the tag ‘resourceModel’.
            I was putting together a dependent filter module, and I needed to override this class: Mage_Catalog_Model_Resource_Eav_Mysql4_Attribute. Just as the above examples, I created this file: My/Module/Model/Catalog/Resource/Eav/Mysql4/Attribute.php, renamed the class, and extended Mage_Catalog_Model_Resource_Eav_Mysql4_Attribute.
            As I said above, the xml syntax changes for resource models. Instead of defining just the ‘catalog’ tag right before the ‘rewrite’, you actually have to define all the way down to the mysql4 folder. Here is an example for the above model:
            >
            > >My_Module_Model> > > > >My_Module_Model_Catalog_Resource_Eav_Mysql4_Attribute> > > >

            Overriding Admin Core Controllers

            I have seen numerous methods on how to do this, but the method I will describe seems to be the current ‘standard’.
            Lets say that I need to override the adminhtml attribute controller: Mage_Adminhtml_Catalog_Product_AttributeController. First thing is to create the controller in your module. I would put mine in My/Module/controllers/Catalog/Product/AtttributeController.php. An important key to note here is that with controllers, Magento does not autoload them like it does with blocks and models. So, we’ll need to include the file of the controller that we want to override. Here is an example of how my controller would look:
            
            include_once("Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php");
            class My_Module_Catalog_Product_AttributeController extends Mage_Adminhtml_Catalog_Product_AttributeController
            {
            ...
            The config.xml file is key now. Unlike models and blocks, you don’t need to define exactly which/where controller you are needing to override. You just need to define whether it is an ‘admin’ or ‘frontend’ controller, which module has the controller(s) you are overriding, and which module you are overriding it with (your own, obviously).
            Here is the example for the above controller:
            >
            > > > > > before="Mage_Adminhtml">My_Module> > > > > > >

            Overriding Frontend Core Controllers

            Lets override the Onepage Checkout controller: Mage_Checkout_OnepageController. First thing is to create the controller in your module. I would put mine in My/Module/controllers/Checkout/OnepageController.php. An important key to note here is that with controllers, Magento does not autoload them like it does with blocks and models. So, we’ll need to include the file of the controller that we want to override. Here is an example of how my controller would look:
            
            include_once('Mage/Checkout/controllers/OnepageController.php');
            class My_Module_Checkout_OnepageController extends Mage_Checkout_OnepageController
            {
            ...
            The config.xml file is key now. Unlike models and blocks, you don’t need to define exactly which/where controller you are needing to override. Unlink overriding an admin controller, here will will put our router info inside the ‘frontend’ tags.
            Here is the example for the above controller:
            >
            > > > > > before="Mage_Checkout">My_Module_Checkout> > > > > > >
            Please feel free to ask questions or provide feedback on this post. If there are any errors or better ways to do any of this, please let me know.

            Источник

            понедельник, 25 февраля 2013 г.

            Optimising Magento for Performance


            Following our earlier entry about installing Magento Enterprise, we thought it would be appropriate to follow up with some tips for getting more from your Magento installation. One of the major criticisms leveled at Magento is its speed; many complain that it is far too slow. In this article we'll go through some steps you can perform to fine-tune your server to allow Magento to run more smoothly and more quickly in a production environment. Our examples are geared at a Debian-based LAMP stack, but most can be adapted for other platforms.


            вторник, 19 февраля 2013 г.

            Magento robots.txt




            Magento robots.txt
            Magento robots.txt
            Magento comes without robots.txt functionality. It can be useful to add one yourself to tell the search engines where they are not allowed to index. It will hide your javascript files, hide SID parameters and prevent some duplicate content. It will help your SEO process and reduces resources on your server. In this blogpost I explain you how to set your own Magento robots.txt using an existing example and using an extension. Both solutions are easy to handle.

            Import/Export Large MYSQL Databases

            When working with MYSQL I often use phpMyAdmin, which is a nice GUI way to manipulate my database. But some operations won't work in phpMyAdmin when the database is too large. In particular, you can't import or export really large databases using phpMyAdmin. So sometimes you need to do things on the command line.

            So I thought I'd document some of the command line snippets we use frequently. In the following, replace [USERNAME] with your mysql username, [DBNAME] with your database name, [/path_to_file/DBNAME] with the path and name of the file used for the database dump, and [/path_to_mysql/] with the path to mysql bin (like /Applications/MAMP/Library/bin/).

            Copy/Export a Large Database

            MYSQL has no 'Copy' function. You create a copy by dumping the database with mysqldump.
            To dump the database and gzip it at the same time, use the following. This will prompt you for your password.

            mysqldump -u [USERNAME] -p [DBNAME] | gzip > [/path_to_file/DBNAME].sql.gz

            Import a Large Database

            If you want to replace the database with a fresh dump created by the above process, do the following.
            First, unzip the file.

            gzip -d [/path_to_file/DBNAME].sql.gz
            Get to a mysql prompt (you will be asked for your password.)

            [/path_to_mysql/]mysql -u [USERNAME] -p
            Then do the following to wipe out the old database and replace it with the new dump:

            SHOW DATABASES;
            DROP DATABASE [DBNAME];
            CREATE DATABASE [DBNAME];
            USE [DBNAME];
            SOURCE [/path_to_file/DBNAME].sql;

            Conditional Dumps

            Sometimes the search index is huge and you want to omit it from the dump. Do so with:

            mysqldump -u [USERNAME] -p [DBNAME] --ignore-table=[DBNAME].search_index | gzip > [/path_to_file/DBNAME].sql.gz
            There are actually a number of tables you could exclude, like the sessions table, the watchdog table and all the cache* tables.
            But if you use the above technique to destroy and recreate the database after doing this, you will be missing all those excluded tables. So you will want to do a two step process instead:
            First, create a backup with ONLY the table information, no data.

            mysqldump -u [USERNAME] -p [DBNAME] --no-data | gzip > [/path_to_file/DBNAME].info.sql.gz
            Then create a backup, including only data from the tables you need.

            [path_to_mysql/]mysqldump -u [USERNAME] -p [DBNAME]  --no-create-info --ignore-table=[DBNAME].search_index --ignore-table=[DBNAME].cache --ignore-table=[DBNAME].cache_block --ignore-table=[DBNAME].cache_content --ignore-table=[DBNAME].cache_filter --ignore-table=[DBNAME].cache_form --ignore-table=[DBNAME].cache_menu --ignore-table=[DBNAME].cache_mollom --ignore-table=[DBNAME].cache_page --ignore-table=[DBNAME].cache_pathdst --ignore-table=[DBNAME].cache_pathsrc --ignore-table=[DBNAME].cache_views | gzip > [/path_to_file/DBNAME].data.sql.gz;
            Well that's a lot of typing. Wouldn't it be nice if there was a wildcard we could use instead of typing out all those cache_ tables? Well there is!! You can do:

            [path_to_mysql/]mysqldump -u [USERNAME] -p [DBNAME]  --no-create-info --ignore-table=[DBNAME].search_index --ignore-table=[DBNAME].cache% | gzip > [/path_to_file/DBNAME].data.sql.gz;
            After doing this, just import the two files as above, first the one with only the table info, and then the data. Result, a (relatively) small database with all the optional tables emptied out.
            Note that the wildcard trick above is not documented anywhere that I can see, so you'll want to test that it works in your setup.

            Источник 

            вторник, 8 января 2013 г.

            Magento аттрибуты

            Отображение атрибутов на странице списка товаров

            Было:
            Изображение

            Стало:
            Изображение