{"id":162313,"date":"2012-12-12T11:48:03","date_gmt":"2012-12-12T07:48:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=162313"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=162313","title":{"rendered":"<span class=\"post_title\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u00ab\u041d\u043e\u0432\u0430\u044f \u043f\u043e\u0447\u0442\u0430\u00bb \u0434\u043b\u044f Magento (\u0447\u0430\u0441\u0442\u044c 2)<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h4>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>  <\/p>\n<ol>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/157647\/\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u00ab\u041d\u043e\u0432\u0430\u044f \u043f\u043e\u0447\u0442\u0430\u00bb \u0434\u043b\u044f Magento (\u0447\u0430\u0441\u0442\u044c 1)<\/a>, \u0433\u0434\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 Magento<\/li>\n<li><b>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u00ab\u041d\u043e\u0432\u0430\u044f \u043f\u043e\u0447\u0442\u0430\u00bb \u0434\u043b\u044f Magento (\u0447\u0430\u0441\u0442\u044c 2), \u0433\u0434\u0435 \u043c\u044b \u0443\u0447\u0438\u043c Magento \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u041d\u043e\u0432\u043e\u0439 \u041f\u043e\u0447\u0442\u043e\u0439 \u0431\u0430\u0437\u0443 \u0441\u043a\u043b\u0430\u0434\u043e\u0432<\/b><\/li>\n<\/ol>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0440\u044b\u0432\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043b\u044f \u0432\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430, \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u043d\u0430\u0447\u0430\u0442\u043e\u0435. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 GitHub: <a href=\"https:\/\/github.com\/alexkuk\/Ak_NovaPoshta\/\">github.com\/alexkuk\/Ak_NovaPoshta\/<\/a>, \u043e\u043d\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e \u0445\u043e\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c API \u043a\u043b\u044e\u0447 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u043a\u043b\u0430\u0434\u043e\u0432 \u0438 \u0433\u043e\u0440\u043e\u0434\u043e\u0432 \u0438\u0437 \u041d\u043e\u0432\u043e\u0439 \u041f\u043e\u0447\u0442\u044b \u0432 \u0431\u0430\u0437\u0443 Magento.<a name=\"habracut\"><\/a><\/p>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0442\u0430\u043a\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0432 \u043f\u0430\u043d\u0435\u043b\u0438 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/1da\/387\/1b7\/1da3871b77e4a4ccf1bc2ebeb967e41f.png\"\/><\/p>\n<h4>API \u041d\u043e\u0432\u043e\u0439 \u041f\u043e\u0447\u0442\u044b<\/h4>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u043e\u0435 \u0432\u043f\u0435\u0447\u0430\u0442\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u041d\u043e\u0432\u0430\u044f \u041f\u043e\u0447\u0442\u0430 \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0439 API \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0436\u0435\u0442. \u0414\u0430\u0436\u0435 \u043e \u0435\u0433\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u044f \u0443\u0437\u043d\u0430\u043b \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0445 \u0444\u043e\u0440\u0443\u043c\u043e\u0432.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u2014 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u043b\u043e\u044f\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0432 \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u041d\u043e\u0432\u043e\u0439 \u041f\u043e\u0447\u0442\u044b. \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043b\u043e\u0433\u0438\u043d \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0432\u043e\u0435\u043c\u0443 \u043b\u0438\u0447\u043d\u043e\u043c\u0443 \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0443. \u041d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u0431\u0438\u043d\u0435\u0442\u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0435\u0442 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u0439 \u043e\u0431 API, \u043d\u043e \u0434\u043e\u0431\u0440\u044b\u0435 \u043b\u044e\u0434\u0438 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430\u0445 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0430\u0434\u0440\u0435\u0441: <a href=\"http:\/\/orders.novaposhta.ua\/api.php?todo=api_form\">orders.novaposhta.ua\/api.php?todo=api_form<\/a>.<\/p>\n<p>  \u0423\u0440\u0430! \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f \u0438 \u0434\u0430\u0436\u0435 \u0444\u043e\u0440\u043c\u0430 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041d\u043e \u043d\u0443\u0436\u0435\u043d \u0435\u0449\u0435 \u0438 \u043a\u043b\u044e\u0447. \u0417\u0434\u0435\u0441\u044c \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u0430\u0441\u044c \u043f\u043e\u043c\u043e\u0449\u044c \u0434\u043e\u0431\u0440\u044b\u0445 \u043b\u044e\u0434\u0435\u0439 \u2014 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0432\u043e\u0439 \u043a\u043b\u044e\u0447, \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0430\u0434\u0440\u0435\u0441\u0443: <a href=\"http:\/\/orders.novaposhta.ua\/api.php?todo=api_get_key_ajax\">orders.novaposhta.ua\/api.php?todo=api_get_key_ajax<\/a>.<\/p>\n<p>  \u0414\u043e\u0441\u0442\u0443\u043f \u043a API \u0435\u0441\u0442\u044c, \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a Magento.<\/p>\n<h4>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u043e\u043f\u0446\u0438\u0438<\/h4>\n<p>  \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u043c URL \u0438 \u043a\u043b\u044e\u0447 API. \u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 API \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0439 \u043b\u043e\u0433.<\/p>\n<p>  \u0412 system.xml \u0432  \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u043e\u043b\u044f:<\/p>\n<pre><code class=\"xml\">                       &lt;api_url translate=&quot;label&quot;&gt;                            &lt;label&gt;API URL&lt;\/label&gt;                            &lt;frontend_type&gt;text&lt;\/frontend_type&gt;                            &lt;sort_order&gt;120&lt;\/sort_order&gt;                            &lt;show_in_default&gt;1&lt;\/show_in_default&gt;                            &lt;show_in_website&gt;0&lt;\/show_in_website&gt;                            &lt;show_in_store&gt;0&lt;\/show_in_store&gt;                        &lt;\/api_url&gt;                        &lt;api_key translate=&quot;label&quot;&gt;                            &lt;label&gt;API key&lt;\/label&gt;                            &lt;frontend_type&gt;text&lt;\/frontend_type&gt;                            &lt;sort_order&gt;130&lt;\/sort_order&gt;                            &lt;show_in_default&gt;1&lt;\/show_in_default&gt;                            &lt;show_in_website&gt;0&lt;\/show_in_website&gt;                            &lt;show_in_store&gt;0&lt;\/show_in_store&gt;                        &lt;\/api_key&gt;                        &lt;enable_log translate=&quot;label&quot;&gt;                            &lt;label&gt;Enable log&lt;\/label&gt;                            &lt;frontend_type&gt;select&lt;\/frontend_type&gt;                            &lt;source_model&gt;adminhtml\/system_config_source_yesno&lt;\/source_model&gt;                            &lt;sort_order&gt;140&lt;\/sort_order&gt;                            &lt;show_in_default&gt;1&lt;\/show_in_default&gt;                            &lt;show_in_website&gt;0&lt;\/show_in_website&gt;                            &lt;show_in_store&gt;0&lt;\/show_in_store&gt;                        &lt;\/enable_log&gt; <\/code><\/pre>\n<p>  \u0412 config.xml \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e:  <\/p>\n<pre><code class=\"xml\">&lt;config&gt;     ...      &lt;default&gt;            &lt;carriers&gt;                    &lt;novaposhta&gt;                        ...                        &lt;api_url&gt;http:\/\/orders.novaposhta.ua\/xml.php&lt;\/api_url&gt;                        &lt;enable_log&gt;0&lt;\/enable_log&gt;                    &lt;\/novaposhta&gt;            &lt;\/carriers&gt;     &lt;\/default&gt;     ... &lt;\/config&gt; <\/code><\/pre>\n<p>  \u0412 \u0445\u0435\u043b\u043f\u0435\u0440\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043b\u043e\u0433. \u0422\u0430\u043a\u0438\u0435 \u043c\u0435\u043b\u043a\u0438\u0435 \u0432\u0435\u0449\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0435 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u044f\u0445 \u043c\u043e\u0434\u0443\u043b\u044f, \u0443\u0434\u043e\u0431\u043d\u043e \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0432 \u0445\u0435\u043b\u043f\u0435\u0440. \u041d\u0443\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e Mage::helper(&#8216;novaposhta&#8217;) \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d \u043d\u0430\u0448\u0435\u0433\u043e \u0445\u0435\u043b\u043f\u0435\u0440\u0430.  <\/p>\n<pre><code class=\"php\">class Ak_NovaPoshta_Helper_Data extends Mage_Core_Helper_Abstract {     protected $_logFile = 'novaposhta.log';      \/**     * @param $string     *     * @return Ak_NovaPoshta_Helper_Data     *\/     public function log($string)     {            if ($this-&gt;getStoreConfig('enable_log')) {                    Mage::log($string, null, $this-&gt;_logFile);            }            return $this;     }      \/**     * @param string $key     * @param null $storeId     *     * @return mixed     *\/     public function getStoreConfig($key, $storeId = null)     {            return Mage::getStoreConfig(&quot;carriers\/novaposhta\/$key&quot;, $storeId);     } } <\/code><\/pre>\n<h4>\u0413\u043e\u0442\u043e\u0432\u0438\u043c \u0411\u0414<\/h4>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0432\u043e\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 Magento \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 <a href=\"http:\/\/codemagento.com\/2011\/02\/altering-the-database-through-setup-scripts\/\">codemagento.com\/2011\/02\/altering-the-database-through-setup-scripts\/<\/a>).<\/p>\n<p>  \u0421\u043f\u0435\u0440\u0432\u0430 \u043e\u043f\u0438\u0448\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441 novaposhta_setup \u0432 config.xml:  <\/p>\n<pre><code class=\"xml\">... &lt;global&gt;        &lt;models&gt;                &lt;novaposhta&gt;                    &lt;class&gt;Ak_NovaPoshta_Model&lt;\/class&gt;                    &lt;resourceModel&gt;novaposhta_resource&lt;\/resourceModel&gt;                &lt;\/novaposhta&gt;                &lt;novaposhta_resource&gt;                    &lt;class&gt;Ak_NovaPoshta_Model_Resource&lt;\/class&gt;                    &lt;entities&gt;                            &lt;city&gt;                                    &lt;table&gt;novaposhta_city&lt;\/table&gt;                            &lt;\/city&gt;                            &lt;warehouse&gt;                                    &lt;table&gt;novaposhta_warehouse&lt;\/table&gt;                            &lt;\/warehouse&gt;                    &lt;\/entities&gt;                &lt;novaposhta_resource&gt;        &lt;\/models&gt;        ...        &lt;resources&gt;                &lt;novaposhta_setup&gt;                    &lt;setup&gt;                            &lt;module&gt;Ak_NovaPoshta&lt;\/module&gt;                    &lt;\/setup&gt;                &lt;\/novaposhta_setup&gt;        &lt;\/resources&gt; &lt;\/global&gt; ... <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c upgrade \u0441\u043a\u0440\u0438\u043f\u0442 app\/code\/community\/Ak\/NovaPoshta\/sql\/novaposhta_setup\/mysql4-upgrade-1.0.0-1.0.1.php, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043d\u0430\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b.  <\/p>\n<pre><code class=\"php\">\/* @var $installer Mage_Core_Model_Resource_Setup *\/ $installer = $this;  $installer-&gt;startSetup();  $installer-&gt;run(&quot; CREATE TABLE {$this-&gt;getTable('novaposhta_city')} (  `id` int(10) unsigned NOT NULL,  `name_ru` varchar(100),  `name_ua` varchar(100),  `updated_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,  PRIMARY KEY (`id`),  INDEX `name_ru` (`name_ru`),  INDEX `name_ua` (`name_ua`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;  CREATE TABLE {$this-&gt;getTable('novaposhta_warehouse')} (  `id` int(10) unsigned NOT NULL,  `city_id` int(10) unsigned NOT NULL,  `address_ru` varchar(200),  `address_ua` varchar(200),  `phone` varchar(100),  `weekday_work_hours` varchar(20),  `weekday_reseiving_hours` varchar(20),  `weekday_delivery_hours` varchar(20),  `saturday_work_hours` varchar(20),  `saturday_reseiving_hours` varchar(20),  `saturday_delivery_hours` varchar(20),  `max_weight_allowed` int(4),  `longitude` float(10,6),  `latitude` float(10,6),  `number_in_city` int(3) unsigned NOT NULL,  `updated_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,  PRIMARY KEY (`id`),  CONSTRAINT FOREIGN KEY (`city_id`) REFERENCES `{$this-&gt;getTable('novaposhta_city')}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; &quot;);  $installer-&gt;endSetup(); <\/code><\/pre>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e \u043c\u043e\u0434\u0443\u043b\u044f \u0434\u043e 1.0.1 \u0432 \u043d\u0430\u0448\u0435\u043c config.xml, \u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u043a\u0435\u0448, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c Magento \u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c, \u0441\u043e\u0437\u0434\u0430\u043b\u0438\u0441\u044c \u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0431\u0430\u0437\u0435. \u0421\u043e\u0437\u0434\u0430\u043b\u0438\u0441\u044c, \u0438\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u0438, \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438<\/h4>\n<p>  \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 city \u0438 warehouse. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u043d\u0438\u043c\u0438, \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 Ak_NovaPoshta_Model_City \u0438 Ak_NovaPoshta_Model_Warehouse. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438\u0445 \u0432 \u0431\u0430\u0437\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u044b Ak_NovaPoshta_Model_Resource_City \u0438 Ak_NovaPoshta_Model_Resource_Warehouse. \u0414\u043b\u044f \u0441\u0432\u044f\u0437\u0438 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u043c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u043c\u0435\u0442\u043e\u0434 _init() c \u0430\u043b\u0438\u0430\u0441\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u0430 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430:  <\/p>\n<pre><code class=\"php\">class Ak_NovaPoshta_Model_City extends Mage_Core_Model_Abstract {     public function _construct()     {            $this-&gt;_init('novaposhta\/city');     } \u2026 } <\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0441\u0443\u0440\u0441\u0435 \u0432\u044b\u0437\u043e\u0432\u0435\u043c _init() \u0440\u0435\u0441\u0443\u0440\u0441\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0430\u043b\u0438\u0430\u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0411\u0414 \u0438 \u0438\u043c\u044f primary key \u043f\u043e\u043b\u044f.  <\/p>\n<pre><code class=\"php\">class Ak_NovaPoshta_Model_Resource_City extends Mage_Core_Model_Resource_Db_Abstract {     public function _construct()     {        $this-&gt;_init('novaposhta\/city', 'id');     } } <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 Ak_NovaPoshta_Model_Resource_City_Collection \u0438 Ak_NovaPoshta_Model_Resource_Warehouse_Collection. \u0412 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 _init() \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0430\u043b\u0438\u0430\u0441 \u043c\u043e\u0434\u0435\u043b\u0438. \u041f\u0440\u0438\u043c\u0435\u0440 Ak_NovaPoshta_Model_Resource_City_Collection:  <\/p>\n<pre><code class=\"php\">class Ak_NovaPoshta_Model_Resource_City_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {     public function _construct()     {        $this-&gt;_init('novaposhta\/city');     } } <\/code><\/pre>\n<h4>\u041c\u043e\u0434\u0435\u043b\u044c \u043a\u043b\u0438\u0435\u043d\u0442\u0430 API<\/h4>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c Ak_NovaPoshta_Model_Api_Client, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 API. \u041a\u043e\u0434 \u043a\u043b\u0438\u0435\u043d\u0442\u0430: <a href=\"https:\/\/github.com\/alexkuk\/Ak_NovaPoshta\/blob\/master\/app\/code\/community\/Ak\/NovaPoshta\/Model\/Api\/Client.php\">github.com\/alexkuk\/Ak_NovaPoshta\/blob\/master\/app\/code\/community\/Ak\/NovaPoshta\/Model\/Api\/Client.php<\/a><br \/>  \u041d\u0430\u0448 \u043d\u043e\u0432\u043e\u0438\u0441\u043f\u0435\u0447\u0435\u043d\u043d\u044b\u0439 \u043a\u043b\u0438\u0435\u043d\u0442 \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430: getCityWarehouses() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0433\u043e\u0440\u043e\u0434\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u041d\u043e\u0432\u043e\u0439 \u041f\u043e\u0447\u0442\u044b, getWarehouses() \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043a\u043b\u0430\u0434\u043e\u0432 \u043f\u043e \u0432\u0441\u0435\u0439 \u0423\u043a\u0440\u0430\u0438\u043d\u0435. \u0414\u0430\u043d\u043d\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 SimpleXMLElement \u043e\u0431\u044a\u0435\u043a\u0442\u0430.<\/p>\n<h4>\u0418\u043c\u043f\u043e\u0440\u0442<\/h4>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u043e\u0434\u0435\u043b\u044c Ak_NovaPoshta_Model_Import: <a href=\"https:\/\/github.com\/alexkuk\/Ak_NovaPoshta\/blob\/master\/app\/code\/community\/Ak\/NovaPoshta\/Model\/Import.php\">github.com\/alexkuk\/Ak_NovaPoshta\/blob\/master\/app\/code\/community\/Ak\/NovaPoshta\/Model\/Import.php<\/a>. \u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u0441\u043c\u044b\u0441\u043b\u0430 \u043d\u0435\u0442. \u041e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u044e\u0441\u044c \u043b\u0438\u0448\u044c \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0435\u0449\u0430\u0445.<\/p>\n<p>  \u042f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0434\u0432\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 $_dataMapCity \u0438 $_dataMapWarehouse, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u044e\u0442 \u0438\u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0435\u0439, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0445 API \u0441 \u0438\u043c\u0435\u043d\u0430\u043c\u0438 \u043f\u043e\u043b\u0435 \u0432 \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u0435. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u043e\u0442 API \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u043e\u0442\u0432\u0435\u0442 \u043a \u043d\u0443\u0436\u043d\u043e\u043c\u0443 \u043d\u0430\u043c \u0432\u0438\u0434\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 _applyMap():  <\/p>\n<pre><code class=\"php\">$cities = $this-&gt;_applyMap($cities, $this-&gt;_dataMapCity); <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0411\u0414 \u043f\u0440\u0438 \u0438\u043c\u043e\u0440\u0442\u0435, \u044f \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043c\u043e\u0434\u0435\u043b\u0438 City \u0438 Warehouse, \u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e SQL \u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0432 \u0435\u0433\u043e \u043d\u0430 \u0447\u0430\u0441\u0442\u0438. \u0417\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e core_write \u0440\u0435\u0441\u0443\u0440\u0441\u0430:<\/p>\n<pre><code class=\"php\">  \/**     * @return Varien_Db_Adapter_Interface     *\/     protected function _getConnection()     {            return Mage::getSingleton('core\/resource')-&gt;getConnection('core_write');     } <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0438 Import \u044f \u0431\u0440\u043e\u0441\u0438\u043b \u0441\u043a\u0440\u0438\u043f\u0442 test.php \u0432 \u043a\u043e\u0440\u0435\u043d\u044c Magento. \u0412 \u043d\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c Magento \u0432\u044b\u0437\u043e\u0432\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0430 Mage::app(), \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0444\u0430\u0431\u0440\u0438\u043a\u043e\u0439 Mage:  <\/p>\n<pre><code class=\"php\">require 'app\/Mage.php'; Mage::app('default'); Mage::getModel('novaposhta\/import')-&gt;runWarehouseAndCityMassImport(); <\/code><\/pre>\n<h4>\u0417\u0430\u043f\u0443\u0441\u043a \u0438\u043c\u043f\u043e\u0440\u0442\u0430 \u043f\u043e CRON\u0443<\/h4>\n<p>  \u0418\u043c\u043f\u043e\u0440\u0442 \u0433\u043e\u0442\u043e\u0432 \u0438 \u043e\u0442\u043b\u0430\u0436\u0435\u043d, \u0445\u043e\u0440\u043e\u0448\u043e \u0431\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e CRON\u0443. \u0412 Magento \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u044f CRON \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0430. \u041f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0443\u0442: <a href=\"http:\/\/www.magentocommerce.com\/wiki\/1_-_installation_and_configuration\/how_to_setup_a_cron_job\">www.magentocommerce.com\/wiki\/1_-_installation_and_configuration\/how_to_setup_a_cron_job<\/a>. \u0412 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445: \u0432 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 Unix cron \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c cron job, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c cron.php \u0438\u043b\u0438 cron.sh \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u0443 CRON Magento. \u0412 \u0440\u0430\u043c\u043a\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u044f\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 config.xml.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0448\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u0432 config.xml:  <\/p>\n<pre><code class=\"xml\">    &lt;crontab&gt;            &lt;jobs&gt;                    &lt;novaposhta_import_city_and_warehouse&gt;                        &lt;schedule&gt;                                &lt;cron_expr&gt;1 2 * * *&lt;\/cron_expr&gt;                        &lt;\/schedule&gt;                        &lt;run&gt;                         &lt;model&gt;ak_novaposhta\/import::runWarehouseAndCityMassImport&lt;\/model&gt;                        &lt;\/run&gt;                    &lt;\/novaposhta_import_city_and_warehouse&gt;            &lt;\/jobs&gt;     &lt;\/crontab&gt; <\/code><\/pre>\n<h4>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441\u043a\u043b\u0430\u0434\u043e\u0432 \u0432 \u043f\u0430\u043d\u0435\u043b\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430<\/h4>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0433\u0440\u0438\u0434\u0430 \u043a\u0430\u043a \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0435 \u0432\u044b\u0448\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u0431\u043b\u043e\u043a\u0430: \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0433\u0440\u0438\u0434\u0430 \u0438 \u043a\u043b\u0430\u0441\u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u0433\u0440\u0438\u0434\u0430. \u041a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043e\u0442 Mage_Adminhtml_Block_Widget_Grid_Container, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043d\u043e\u043f\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u0441\u0430\u043c \u0433\u0440\u0438\u0434 Mage_Adminhtml_Block_Widget_Grid.<\/p>\n<p>  \u0410\u0445 \u0434\u0430, \u0435\u0449\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \ud83d\ude42<\/p>\n<p>  \u0418\u0442\u0430\u043a, Ak_NovaPoshta_Block_Adminhtml_Warehouses:  <\/p>\n<pre><code class=\"php\">class Ak_NovaPoshta_Block_Adminhtml_Warehouses extends Mage_Adminhtml_Block_Widget_Grid_Container {     public function __construct()     {            \/\/ $this-&gt;_blockGroup \u0438 $this-&gt;_controller \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 _prepareLayout() \u043d\u0430\u0448\u0435\u043b \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0433\u0440\u0438\u0434\u0430 (novaposhta\/adminhtml_warehouses). \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u0430\u0442\u044c _prepareLayout().            $this-&gt;_blockGroup = 'novaposhta';            $this-&gt;_controller = 'adminhtml_warehouses';            this-&gt;_headerText = $this-&gt;__('Manage warehouses');             parent::__construct();            \/\/ \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0443 add, \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u0443\u044e \u0432 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435, \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043a\u043b\u0430\u0434\u044b \u0438\u0437 \u0430\u0434\u043c\u0438\u043d\u043a\u0438            $this-&gt;_removeButton('add');            \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0432\u043e\u044e \u043a\u043d\u043e\u043f\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e            $this-&gt;_addButton('synchronize', array(                    'label'     =&gt; $this-&gt;__('Synchronize with API'),                    'onclick'   =&gt; 'setLocation(\\'' . $this-&gt;getUrl('*\/*\/synchronize') .'\\')'            ));     } } <\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441 \u0433\u0440\u0438\u0434\u0430:  <\/p>\n<pre><code class=\"php\">class Ak_NovaPoshta_Block_Adminhtml_Warehouses_Grid extends Mage_Adminhtml_Block_Widget_Grid {     public function __construct()     {            parent::__construct();            $this-&gt;setDefaultSort('city_id');            $this-&gt;setId('warehousesGrid');            $this-&gt;setDefaultDir('asc');            $this-&gt;setSaveParametersInSession(true);     }      protected function _prepareCollection()     {            \/** @var $collection Ak_NovaPoshta_Model_Resource_Warehouse_Collection *\/            $collection = Mage::getModel('novaposhta\/warehouse')                    -&gt;getCollection();             $this-&gt;setCollection($collection);            return parent::_prepareCollection();     }      protected function _prepareColumns()     {            \/\/ \u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0433\u0440\u0438\u0434\u0430            $this-&gt;addColumn('id',                    array(                        'header' =&gt; $this-&gt;__('ID'),                        'align' =&gt;'right',                        'width' =&gt; '50px',                        'index' =&gt; 'id'                    )            );             $this-&gt;addColumn('address_ru',                    array(                        'header' =&gt; $this-&gt;__('Address (ru)'),                        'index' =&gt; 'address_ru'                    )            );             $this-&gt;addColumn('city_id',                    array(                         'header' =&gt; $this-&gt;__('City'),                         'index' =&gt; 'city_id',                         'type'  =&gt; 'options',                         \/\/ \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043e\u043f\u0446\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438 City \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0433\u043e\u0440\u043e\u0434\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u043e \u201c\u0441\u0443\u0445\u0438\u0445\u201d \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432                         'options' =&gt; Mage::getModel('novaposhta\/city')-&gt;getOptionArray()                    )            );             $this-&gt;addColumn('phone',                    array(                         'header' =&gt; $this-&gt;__('Phone'),                         'index' =&gt; 'phone'                    )            );             $this-&gt;addColumn('max_weight_allowed',                    array(                         'header' =&gt; $this-&gt;__('Max weight'),                         'index' =&gt; 'max_weight_allowed'                    )            );             return parent::_prepareColumns();     }      \/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c false - \u043d\u0435 \u0445\u043e\u0442\u0438\u043c \u0434\u0430\u0432\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438     public function getRowUrl($row)     {            return false;     }  } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440. \u0422\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435 \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u043a\u0438, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u043c\u0441\u044f \u043e\u0442 Mage_Adminhtml_Controller_Action.  <\/p>\n<pre><code class=\"php\">class Ak_NovaPoshta_WarehousesController extends Mage_Adminhtml_Controller_Action {     \/**     * \u0437\u0434\u0435\u0441\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0431\u043b\u043e\u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0433\u0440\u0438\u0434\u0430 \u0438 \u0440\u0435\u043d\u0434\u0435\u0440\u0438\u043c     * \/     public function indexAction()     {            $this-&gt;_title($this-&gt;__('Sales'))-&gt;_title($this-&gt;__('Nova Poshta Warehouses'));             $this-&gt;_initAction()            -&gt;_addContent($this-&gt;getLayout()-&gt;createBlock('novaposhta\/adminhtml_warehouses'))            -&gt;renderLayout();         return $this;     }      \/**     * \u0437\u0434\u0435\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e     * \/     public function synchronizeAction()     {        try {            Mage::getModel('novaposhta\/import')-&gt;runWarehouseAndCityMassImport();            \/\/ \u0423\u0441\u043f\u0435\u0445, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c success message \u0432 \u0441\u0442\u0435\u043a \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439            $this-&gt;_getSession()-&gt;addSuccess($this-&gt;__('City and Warehouse API synchronization finished'));        }        catch (Exception $e) {              \/\/ \u0418\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c error message \u0432 \u0441\u0442\u0435\u043a \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0439            $this-&gt;_getSession()-&gt;addError($this-&gt;__('Error during synchronization: %s', $e-&gt;getMessage()));        }         \/\/ \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u043c \u0433\u0440\u0438\u0434\u0430        $this-&gt;_redirect('*\/*\/index');         return $this;     }      \/**     * Initialize action     *     * @return Ak_NovaPoshta_WarehousesController     *\/     protected function _initAction()     {        $this-&gt;loadLayout()            -&gt;_setActiveMenu('sales\/novaposhta\/warehouses')            -&gt;_addBreadcrumb($this-&gt;__('Sales'), $this-&gt;__('Sales'))            -&gt;_addBreadcrumb($this-&gt;__('Nova Poshta Warehouses'), $this-&gt;__('Nova Poshta Warehouses'))        ;        return $this;     } } <\/code><\/pre>\n<p>  \u041d\u043e \u044d\u0442\u043e \u0435\u0449\u0435 \u043d\u0435 \u0432\u0441\u0435. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0440\u043e\u0443\u0442 \u0432 config.xml, \u0447\u0442\u043e\u0431\u044b Magento \u0441\u043c\u043e\u0433\u043b\u0430 \u043d\u0430\u0439\u0442\u0438 \u043d\u0430\u0448 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440.  <\/p>\n<pre><code class=\"xml\">&lt;config&gt; ...     &lt;admin&gt;        &lt;routers&gt;            &lt;novaposhta&gt;                &lt;use&gt;admin&lt;\/use&gt;                &lt;args&gt;                    &lt;module&gt;Ak_NovaPoshta&lt;\/module&gt;                    &lt;frontName&gt;novaposhta&lt;\/frontName&gt;                &lt;\/args&gt;            &lt;\/novaposhta&gt;        &lt;\/routers&gt;     &lt;\/admin&gt; ... &lt;\/config&gt; <\/code><\/pre>\n<p>  \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u043d\u043a\u0442 \u0432 \u043c\u0435\u043d\u044e \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432 ACL. \u0412\u0441\u0435 \u044d\u0442\u043e \u0432\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 adminhtml.xml:  <\/p>\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot;?&gt; &lt;config&gt;     &lt;menu&gt;         &lt;sales&gt;            &lt;children&gt;                &lt;novaposhta translate=&quot;title&quot; module=&quot;novaposhta&quot;&gt;                    &lt;sort_order&gt;200&lt;\/sort_order&gt;                    &lt;title&gt;Nova Poshta&lt;\/title&gt;                    &lt;children&gt;                        &lt;warehouses translate=&quot;title&quot; module=&quot;novaposhta&quot;&gt;                            &lt;sort_order&gt;10&lt;\/sort_order&gt;                            &lt;title&gt;Warehouses&lt;\/title&gt;                            &lt;action&gt;novaposhta\/warehouses\/&lt;\/action&gt;                        &lt;\/warehouses&gt;                    &lt;\/children&gt;                &lt;\/novaposhta&gt;            &lt;\/children&gt;         &lt;\/sales&gt;     &lt;\/menu&gt;     &lt;acl&gt;        &lt;resources&gt;            &lt;admin&gt;                &lt;children&gt;                    &lt;sales&gt;                        &lt;children&gt;                            &lt;novaposhta translate=&quot;title&quot; module=&quot;novaposhta&quot;&gt;                                &lt;title&gt;Nova Poshta&lt;\/title&gt;                                &lt;sort_order&gt;200&lt;\/sort_order&gt;                                &lt;children&gt;                                    &lt;warehouses translate=&quot;title&quot; module=&quot;novaposhta&quot;&gt;                                        &lt;sort_order&gt;10&lt;\/sort_order&gt;                                        &lt;title&gt;Warehouses&lt;\/title&gt;                                    &lt;\/warehouses&gt;                                &lt;\/children&gt;                            &lt;\/novaposhta&gt;                        &lt;\/children&gt;                    &lt;\/sales&gt;                &lt;\/children&gt;            &lt;\/admin&gt;        &lt;\/resources&gt;     &lt;\/acl&gt; &lt;\/config&gt; <\/code><\/pre>\n<h4>\u0413\u043e\u0442\u043e\u0432\u043e<\/h4>\n<p>  \u0423 \u043d\u0430\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0435\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0441\u043a\u043b\u0430\u0434\u043e\u0432. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u2014 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u043a\u043b\u0430\u0434\u044b \u041d\u043e\u0432\u043e\u0439 \u041f\u043e\u0447\u0442\u044b \u0432 \u0443\u0434\u043e\u0431\u043d\u043e\u043c \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0432\u0438\u0434\u0435 \u043d\u0430 \u0448\u0430\u0433\u0435 Shipping Method \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043a\u0430\u0437\u0430, \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u043b\u0430\u0434\u044b \u0432 \u0433\u043e\u0440\u043e\u0434\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.<\/p>\n<p>  \u0411\u0443\u0434\u0443 \u0440\u0430\u0434 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u043c, \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c \ud83d\ude42    \t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/162313\/\"> http:\/\/habrahabr.ru\/post\/162313\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h4>\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>  <\/p>\n<ol>\n<li><a href=\"http:\/\/habrahabr.ru\/post\/157647\/\">\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u00ab\u041d\u043e\u0432\u0430\u044f \u043f\u043e\u0447\u0442\u0430\u00bb \u0434\u043b\u044f Magento (\u0447\u0430\u0441\u0442\u044c 1)<\/a>, \u0433\u0434\u0435 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0432 Magento<\/li>\n<li><b>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u00ab\u041d\u043e\u0432\u0430\u044f \u043f\u043e\u0447\u0442\u0430\u00bb \u0434\u043b\u044f Magento (\u0447\u0430\u0441\u0442\u044c 2), \u0433\u0434\u0435 \u043c\u044b \u0443\u0447\u0438\u043c Magento \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u041d\u043e\u0432\u043e\u0439 \u041f\u043e\u0447\u0442\u043e\u0439 \u0431\u0430\u0437\u0443 \u0441\u043a\u043b\u0430\u0434\u043e\u0432<\/b><\/li>\n<\/ol>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0440\u044b\u0432\u0430, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0434\u043b\u044f \u0432\u0440\u0435\u0434\u043d\u043e\u0433\u043e \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0430, \u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0443 \u043d\u0430\u0447\u0430\u0442\u043e\u0435. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u0432\u0441\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 GitHub: <a href=\"https:\/\/github.com\/alexkuk\/Ak_NovaPoshta\/\">github.com\/alexkuk\/Ak_NovaPoshta\/<\/a>, \u043e\u043d\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043f\u043e \u0445\u043e\u0434\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c API \u043a\u043b\u044e\u0447 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0430\u0446\u0438\u044e \u0441\u043a\u043b\u0430\u0434\u043e\u0432 \u0438 \u0433\u043e\u0440\u043e\u0434\u043e\u0432 \u0438\u0437 \u041d\u043e\u0432\u043e\u0439 \u041f\u043e\u0447\u0442\u044b \u0432 \u0431\u0430\u0437\u0443 Magento.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-162313","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/162313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=162313"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/162313\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=162313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=162313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=162313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}