<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум ReadyScript &mdash; Добавление поля в таблицу order_address [Решено]]]></title>
	<link rel="self" href="http://forum.readyscript.ru/feed/atom/topic/1004/" />
	<updated>2016-11-23T10:29:33Z</updated>
	<generator>PunBB</generator>
	<id>http://forum.readyscript.ru/topic/1004/dobavlenie-polya-v-tablitsu-orderaddress-resheno/</id>
		<entry>
			<title type="html"><![CDATA[Re: Добавление поля в таблицу order_address [Решено]]]></title>
			<link rel="alternate" href="http://forum.readyscript.ru/post/5391/#p5391" />
			<content type="html"><![CDATA[<p><strong>Закусило Александр, </strong> блин моя не внимательность, прошу прощения</p>]]></content>
			<author>
				<name><![CDATA[Илья]]></name>
				<uri>http://forum.readyscript.ru/user/286/</uri>
			</author>
			<updated>2016-11-23T10:29:33Z</updated>
			<id>http://forum.readyscript.ru/post/5391/#p5391</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Добавление поля в таблицу order_address [Решено]]]></title>
			<link rel="alternate" href="http://forum.readyscript.ru/post/5384/#p5384" />
			<content type="html"><![CDATA[<p>И где у Вас записывается <strong>addr_person</strong> из POST ?</p>]]></content>
			<author>
				<name><![CDATA[Закусило Александр]]></name>
				<uri>http://forum.readyscript.ru/user/20/</uri>
			</author>
			<updated>2016-11-23T09:05:26Z</updated>
			<id>http://forum.readyscript.ru/post/5384/#p5384</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Добавление поля в таблицу order_address [Решено]]]></title>
			<link rel="alternate" href="http://forum.readyscript.ru/post/5383/#p5383" />
			<content type="html"><![CDATA[<p>там все норм как раз таки var_dump($_POST[&#039;addr_person&#039;]); string(14) &quot;персона&quot;<br /></p><div class="codebox"><pre><code>if (isset($_POST[&#039;person&#039;]) || isset($_POST[&#039;addr_person&#039;])){ 
            $address[&#039;person&#039;] = \RS\Http\Request::commonInstance()-&gt;request(&#039;person&#039;, TYPE_STRING); 
        }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Илья]]></name>
				<uri>http://forum.readyscript.ru/user/286/</uri>
			</author>
			<updated>2016-11-23T08:58:25Z</updated>
			<id>http://forum.readyscript.ru/post/5383/#p5383</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Добавление поля в таблицу order_address [Решено]]]></title>
			<link rel="alternate" href="http://forum.readyscript.ru/post/5381/#p5381" />
			<content type="html"><![CDATA[<p>Смотрите что у Вас в POST находится через var_dump.</p>]]></content>
			<author>
				<name><![CDATA[Закусило Александр]]></name>
				<uri>http://forum.readyscript.ru/user/20/</uri>
			</author>
			<updated>2016-11-23T08:55:45Z</updated>
			<id>http://forum.readyscript.ru/post/5381/#p5381</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Добавление поля в таблицу order_address [Решено]]]></title>
			<link rel="alternate" href="http://forum.readyscript.ru/post/5380/#p5380" />
			<content type="html"><![CDATA[<p>Блин точно. Но почему заносится пустое значение? Т.е. в таблице NULL пропало и теперь просто пустая ячейка</p>]]></content>
			<author>
				<name><![CDATA[Илья]]></name>
				<uri>http://forum.readyscript.ru/user/286/</uri>
			</author>
			<updated>2016-11-23T08:48:28Z</updated>
			<id>http://forum.readyscript.ru/post/5380/#p5380</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Добавление поля в таблицу order_address [Решено]]]></title>
			<link rel="alternate" href="http://forum.readyscript.ru/post/5376/#p5376" />
			<content type="html"><![CDATA[<p>А почему Вы в POST проверяете person? Какое у Вас имя поля, которое хранит персону?</p>]]></content>
			<author>
				<name><![CDATA[Закусило Александр]]></name>
				<uri>http://forum.readyscript.ru/user/20/</uri>
			</author>
			<updated>2016-11-23T08:40:27Z</updated>
			<id>http://forum.readyscript.ru/post/5376/#p5376</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Добавление поля в таблицу order_address [Решено]]]></title>
			<link rel="alternate" href="http://forum.readyscript.ru/post/5374/#p5374" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Закусило Александр пишет:</cite><blockquote><div class="codebox"><pre><code>orm.beforewrite.shop-address</code></pre></div></blockquote></div><p>Как раз пробовал третьим вариантом, что то не получается. Код что я выложил выше, там этот хук использую. Но как происвоить адресу?<br /></p><div class="codebox"><pre><code>if (isset($_POST[&#039;person&#039;])){ 
            $address[&#039;addr_person&#039;] = \RS\Http\Request::commonInstance()-&gt;request(&#039;addr_person&#039;, TYPE_STRING); 
        }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Илья]]></name>
				<uri>http://forum.readyscript.ru/user/286/</uri>
			</author>
			<updated>2016-11-23T08:27:56Z</updated>
			<id>http://forum.readyscript.ru/post/5374/#p5374</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Добавление поля в таблицу order_address [Решено]]]></title>
			<link rel="alternate" href="http://forum.readyscript.ru/post/5372/#p5372" />
			<content type="html"><![CDATA[<p>Оно не относится к оформлению заказа. Это же объект адреса. В админ. панели когда указываете адрес и нажимаете сохранить отправляются данные на сохранение адреса. А не сохраняется он потому, что в методе <strong>actionDeliveryDialog</strong> в контроллере <strong>/shop/controller/admin/orderctrl.inc.php</strong> там сохраняются конкретные поля. Тут можно тремя методами поступить перегрузить этот файл через .my.inc.php. Либо написать обращение в поддержку, чтобы добавили поддержку сохранения и других полей. Ну и третий подвесится на хук перед сохранением объекта адреса и проверить есть ли в посте данные по персоне и если есть, то присвоить адресу.<br /></p><div class="codebox"><pre><code>orm.beforewrite.shop-address</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Закусило Александр]]></name>
				<uri>http://forum.readyscript.ru/user/20/</uri>
			</author>
			<updated>2016-11-23T08:20:51Z</updated>
			<id>http://forum.readyscript.ru/post/5372/#p5372</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Добавление поля в таблицу order_address [Решено]]]></title>
			<link rel="alternate" href="http://forum.readyscript.ru/post/5369/#p5369" />
			<content type="html"><![CDATA[<p>Здравствуйте. <br />Добавил новое поле в таблицу <strong>order_address</strong><br /><a href="http://itmages.ru/image/view/5225632/1f329a06"><span class="postimg"><img src="http://storage5.static.itmages.ru/i/16/1123/s_1479886461_9331343_1f329a06a6.png" alt="http://storage5.static.itmages.ru/i/16/1123/s_1479886461_9331343_1f329a06a6.png" /></span></a></p><p>Если через админку заказа вводить данные в это поле<br /><a href="http://itmages.ru/image/view/5225636/dd76c187"><span class="postimg"><img src="http://storage1.static.itmages.ru/i/16/1123/s_1479886506_9957165_dd76c187b1.png" alt="http://storage1.static.itmages.ru/i/16/1123/s_1479886506_9957165_dd76c187b1.png" /></span></a></p><p>то данные заносятся<br /><a href="http://itmages.ru/image/view/5225638/ba83d936"><span class="postimg"><img src="http://storage3.static.itmages.ru/i/16/1123/s_1479886525_8672629_ba83d93670.png" alt="http://storage3.static.itmages.ru/i/16/1123/s_1479886525_8672629_ba83d93670.png" /></span></a></p><p>А при оформлении заказа не заносятся<br /><a href="http://itmages.ru/image/view/5225642/b1a05b23"><span class="postimg"><img src="http://storage6.static.itmages.ru/i/16/1123/s_1479886577_8525466_b1a05b237f.png" alt="http://storage6.static.itmages.ru/i/16/1123/s_1479886577_8525466_b1a05b237f.png" /></span></a></p><p>Подскажите что нужно указать в своем модуле?Наверное еще какой то хук?<br /></p><div class="codebox"><pre><code>&lt;?php
namespace Person\Config;
use \RS\Orm\Type as OrmType;

class Handlers extends \RS\Event\HandlerAbstract
{
function init()
    {
        $this
            -&gt;bind(&#039;orm.init.shop-address&#039;)
            -&gt;bind(&#039;orm.beforewrite.shop-address&#039;);
    }
    
   
    public static function ormInitShopAddress (\Shop\Model\Orm\Address $address )
    {
        $address-&gt;getPropertyIterator()-&gt;append(array(
            &#039;person&#039; =&gt; new OrmType\Varchar(array(
                    &#039;maxLength&#039; =&gt; &#039;100&#039;,
                    &#039;description&#039; =&gt; t(&#039;Персона&#039;),
            )),

        ));
    } 

    /**
    * Действия перез записью заказа в БД
    */
    public static function ormBeforeWriteShopAddress ($data) {
        
        /**
        * @var \Shop\Model\Orm\Order
        */ 
        $address = $data[&#039;orm&#039;];//Получаем объект заказа
        $flag = $data[&#039;flag&#039;];//флаг

                
        if (isset($_POST[&#039;person&#039;])){ 
            $address[&#039;person&#039;] = \RS\Http\Request::commonInstance()-&gt;request(&#039;person&#039;, TYPE_STRING); 
        }
        // var_dump($address);
        

    }
 
}</code></pre></div><p><strong>Решение</strong><br /><span class="bbu">Создаем собственный модуль</span></p><p><strong>person/config/handlers.inc.php</strong><br /></p><div class="codebox"><pre><code>&lt;?php
namespace Person\Config;
use \RS\Orm\Type as OrmType;

class Handlers extends \RS\Event\HandlerAbstract
{
function init()
    {
        $this
            -&gt;bind(&#039;orm.init.shop-address&#039;)
            -&gt;bind(&#039;orm.beforewrite.shop-address&#039;);
    }
    
   
    public static function ormInitShopAddress (\Shop\Model\Orm\Address $address )
    {
        $address-&gt;getPropertyIterator()-&gt;append(array(
            &#039;person&#039; =&gt; new OrmType\Varchar(array(
                    &#039;maxLength&#039; =&gt; &#039;100&#039;,
                    &#039;description&#039; =&gt; t(&#039;Получатель&#039;),
            )),

        ));
    } 

    /**
    * Действия перез записью заказа в БД
    */
    public static function ormBeforeWriteShopAddress ($data) {
        
        /**
        * @var \Shop\Model\Orm\Order
        */ 
        $address = $data[&#039;orm&#039;];//Получаем объект заказа
        $flag = $data[&#039;flag&#039;];//флаг

                
        if (isset($_POST[&#039;person&#039;]) || isset($_POST[&#039;addr_person&#039;])){ 
            $address[&#039;person&#039;] = \RS\Http\Request::commonInstance()-&gt;request(&#039;person&#039;, TYPE_STRING); 
        }         
        

    }
 
}</code></pre></div><p><strong>person/config/file.inc.php</strong><br /></p><div class="codebox"><pre><code>&lt;?php
namespace Person\Config;
use \RS\Orm\Type;


class File extends \RS\Orm\ConfigObject
{
   
    
}</code></pre></div><p><strong>person/config/module.xml</strong><br /></p><div class="codebox"><pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;config&gt;
    &lt;defaultValues&gt;    
        &lt;name multilanguage=&quot;true&quot;&gt;Расширение таблицы с адресами заказов&lt;/name&gt;
        &lt;description multilanguage=&quot;true&quot;&gt;Модуль добавляет новые поля в таблицу адресов пользователя&lt;/description&gt;        
        &lt;version&gt;1.0.0.0&lt;/version&gt;
        &lt;author&gt;My mod&lt;/author&gt;      
    &lt;/defaultValues&gt;
&lt;/config&gt;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Илья]]></name>
				<uri>http://forum.readyscript.ru/user/286/</uri>
			</author>
			<updated>2016-11-23T07:30:51Z</updated>
			<id>http://forum.readyscript.ru/post/5369/#p5369</id>
		</entry>
</feed>
