<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Magento Solutions Blog (IT)</title>
	<atom:link href="http://www.magentosolutions.it/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://www.magentosolutions.it/blog</link>
	<description>Appunti, note, rilfessioni per fissare le nostre esperienze su Magento.</description>
	<lastBuildDate>Thu, 15 Sep 2011 15:20:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Metodi di pagamento, authorize, capture: qualche appunto</title>
		<link>http://www.magentosolutions.it/blog/2011/09/15/metodi-di-pagamento-authorize-capture-qualche-appunto.html</link>
		<comments>http://www.magentosolutions.it/blog/2011/09/15/metodi-di-pagamento-authorize-capture-qualche-appunto.html#comments</comments>
		<pubDate>Thu, 15 Sep 2011 15:00:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Senza categoria]]></category>

		<guid isPermaLink="false">http://www.magentosolutions.it/blog/?p=293</guid>
		<description><![CDATA[In rete esistono alcuni ottimi post su come implementare un nuovo metodo di pagamento e sulle tematiche connesse (vedi link a fine pagina). Tuttavia si trovano pochissimi risultati che illustrino quali siano gli oggetti coinvolti nel processo di pagamento e come essi interagiscano fra loro. In questi giorni abbiamo provato a ricostruire il processo: di [...]]]></description>
			<content:encoded><![CDATA[<p>In rete esistono alcuni ottimi post su come implementare un nuovo metodo di pagamento e sulle tematiche connesse (vedi link a fine pagina).</p>
<p>Tuttavia si trovano pochissimi risultati che illustrino quali siano gli oggetti coinvolti nel processo di pagamento e come essi interagiscano fra loro. In questi giorni abbiamo provato a ricostruire il processo: di seguito riportiamo i risultati di tale ricostruzione basata su Magento CE 1.5.1.<span id="more-293"></span></p>
<p>Innanzitutto illustriamo i principali soggetti coinvolti.</p>
<ul>
<li><strong>Mage_Sales_Model_Order </strong>è l&#8217;oggetto order vero e proprio. Tutte le azioni passano da qui: place(), cancel(), invoice()&#8230;</li>
<li><strong>Mage_Sales_Model_Order_Payment </strong>è un oggetto pagamento generico. È quello che si ottiene da order con $order-&gt;getPayment().</li>
<li>Il nostro metodo di pagamento che sarà normalmente un estensione di <strong>Mage_Payment_Model_Method_Abstract</strong>. Si ottiene dal Payment con un <strong>$this-&gt;getMethodInstance()</strong></li>
</ul>
<ol>
<li>Viene invocata l&#8217;azione <strong>saveOrder</strong> di <strong>Mage_Checkout_OnepageController</strong>. Tra le varie istruzioni questa azione chiama

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>399
</pre></td><td class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #0000ff;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOnepage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveOrder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>il quale chiama il metodo <strong>saveOrder()</strong> di <strong>Mage_Checkout_Model_Type_Onepage. </strong>Questo invoca il comando</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>742
</pre></td><td class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #0000ff;">$service</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">submitAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>il quale chiama il metodo <strong>submitAll() </strong>e quindi <strong>submitOrder()</strong> di <strong>Mage_Sales_Model_Service_Quote. </strong><strong><br />
</strong>Arrivati a questo punto finalmente viene eseguito il <strong>place()</strong> dell&#8217;order tramite le istruzioni.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>173
174
175
</pre></td><td class="code"><pre class="php-brief" style="font-family:monospace;"><span style="color: #0000ff;">$transaction</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addObject</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$order</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$transaction</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addCommitCallback</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$order</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'place'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$transaction</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addCommitCallback</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$order</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'save'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Se vi aspettavate di trovare da qualche parte del codice un bel <strong>$order-&gt;place()</strong>&#8230; Magento is never easy!</li>
<li>La funzione <strong>place()</strong> di <strong>Mage_Sales_Model_Order</strong> è la funzione che da il via al processo di pagamento. Oltre a lanciare gli eventi correlati, infatti lancia _placePayment che effettua il pagamento tramite l&#8217;oggetto <strong>Mage_Sales_Model_Order_Payment</strong></li>
<li>La funzione <strong>place()</strong> di <strong>Mage_Sales_Model_Order_Payment</strong> effettua molte operazioni.
<ul>
<li>cambia lo stato prima a New poi a Processing</li>
<li>imposta tutti i parametri del pagamento (importo, costi spedizione&#8230;)</li>
<li>distingue se il metodo di Pagamento è <em>Authorize</em> oppure <em>Authorize and Capture</em>. Nel primo caso lancia il comando <strong>_authorize</strong> nel secondo il comando <strong>capture</strong></li>
</ul>
</li>
<li>Analizziamo in prima battuta il caso authorize. La funzione _authorize chiama a sua volta la funzione <strong>authorize</strong> che sarà definita nel nostro metodo di pagamento (che estenderà una funzione praticamente vuota presente in <strong>Mage_Payment_Model_Method_Abstract).</strong> authorize normalmente conterrà tutte le istruzioni che si interfacciano con il webservice della banca. Tra le altre dovrà contenere anche le istruzioni di creazione di un oggetto di tipo sales/order_payment_transaction. Questo passaggio è importante per la fase di cancellazione: senza transaction la cancellazione è impossibile.</li>
</ol>
<hr />
<h5>Kingdom of Roi:</h5>
<p><a rel="bookmark" href="http://roysimkes.net/blog/2009/11/creating-your-own-payment-gateway-for-magento-part-1/" target="_blank">Creating Your Own Payment Gateway For Magento – Part 1<br />
</a><a rel="bookmark" href="http://roysimkes.net/blog/2009/11/creating-your-own-payment-gateway-for-magento-%E2%80%93-part-2/" target="_blank">Creating Your Own Payment Gateway For Magento – Part 2<br />
</a><a rel="bookmark" href="http://roysimkes.net/blog/2010/06/creating-your-own-payment-gateway-for-magento%E2%80%93part-3/" target="_blank">Creating Your Own Payment Gateway For Magento – Part 3</a><a rel="bookmark" href="http://roysimkes.net/blog/2009/11/creating-your-own-payment-gateway-for-magento-part-1/" target="_blank"></a></p>
<h5>Alan Storm:</h5>
<p><a href="http://stackoverflow.com/questions/5366551/magento-payment-flow">Magento Payment flow</a></p>
<h5>Stephen Gray:</h5>
<p><a href="http://colourgray.wordpress.com/2009/11/11/magento-create-a-custom-payment-method/" target="_blank">Magento create a custom payment method</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentosolutions.it/blog/2011/09/15/metodi-di-pagamento-authorize-capture-qualche-appunto.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Importazione a 2000 prodotti/minuto? MagMI!</title>
		<link>http://www.magentosolutions.it/blog/2011/09/15/importazione-a-2000-prodottiminuto-magmi.html</link>
		<comments>http://www.magentosolutions.it/blog/2011/09/15/importazione-a-2000-prodottiminuto-magmi.html#comments</comments>
		<pubDate>Thu, 15 Sep 2011 13:52:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Moduli]]></category>
		<category><![CDATA[Programmazione]]></category>

		<guid isPermaLink="false">http://www.magentosolutions.it/blog/?p=291</guid>
		<description><![CDATA[In un precedente post abbiamo illustrato un modo per automatizzare l'importazione dei prodotti.

Da qualche tempo in Magento Solutions abbiamo abbandonato l'importazione classica di Magento (che usa i moduli DataFlow) per problemi di performance dato che il ritmo di DataFlow è di 50-100 prodotti/minuto.
La soluzione che utilizziamo correntemente è il Magento Mass Importer sviluppato da Dweeves sul forum di Magento.]]></description>
			<content:encoded><![CDATA[<p>In un <a href="http://www.magentosolutions.it/blog/2010/01/11/eseguire-in-batch-un-profilo-di-importazione.html" target="_blank">precedente post</a> abbiamo illustrato un modo per automatizzare l&#8217;importazione dei prodotti.</p>
<p>Da qualche tempo in Magento Solutions abbiamo abbandonato l&#8217;importazione classica di Magento (che usa i moduli DataFlow) per problemi di performance dato che il ritmo di DataFlow è di 50-100 prodotti/minuto.<br />
Sebbene in Magento 1.5 anche la Varien abbia inserito un nuovo importatore con prestazioni migliorate, la soluzione che utilizziamo correntemente è il <a title="http://sourceforge.net/apps/mediawiki/magmi/" href="http://">Magento Mass Importer</a> sviluppato da Dweeves sul <a href="http://www.magentocommerce.com/boards/viewthread/201210" target="_self">forum di Magento</a>.</p>
<p>Il MagMI oltre a risolvere molti dei problemi che con DataFlow rimanevano irrisolti (importazione dei configurabili, importazione delle immagini, related, crosssell, upsell, tier prices) ha una velocità considerevole che si attesta sui 1500-2500 prodotti/min (e la velocità arriva anche a 5000-6000 in caso di aggiornamento di un singolo attributo come la disponibilità o il prezzo).<br />
Inoltre MagMI ha una struttura a plugin per cui si possono aggiungere facilmente nuove funzionalità.</p>
<p>Un grande grazie a Dweeves per averci messo a disposizione uno strumento tanto potente e completo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentosolutions.it/blog/2011/09/15/importazione-a-2000-prodottiminuto-magmi.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Correzione del Motore di Ricerca di Magento 1.4.2</title>
		<link>http://www.magentosolutions.it/blog/2011/04/08/correzione-del-motore-di-ricerca-di-magento-1-4-2.html</link>
		<comments>http://www.magentosolutions.it/blog/2011/04/08/correzione-del-motore-di-ricerca-di-magento-1-4-2.html#comments</comments>
		<pubDate>Fri, 08 Apr 2011 14:20:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Senza categoria]]></category>

		<guid isPermaLink="false">http://www.magentosolutions.it/blog/?p=287</guid>
		<description><![CDATA[La quick search presenta un baco in Magento 1.4.2: i risultati sono sempre gli stessi indipendentemente dalla parola inserita nel form di ricerca. Tale baco è stato risolto in Magento 1.5. Riportiamo qui di seguito la correzione da fare per propagare la correzione anche in Magento 1.4.2: Nel file app/code/core/Mage/CatalogSearch/Model/MySQL4/Fulltext.php bisogna sostituire la riga 342: [...]]]></description>
			<content:encoded><![CDATA[<p>La quick search presenta un baco in Magento 1.4.2: i risultati sono sempre gli stessi indipendentemente dalla parola inserita nel form di ricerca.</p>
<p>Tale baco è stato risolto in Magento 1.5. Riportiamo qui di seguito la correzione da fare per propagare la correzione anche in Magento 1.4.2:</p>
<p>Nel file <strong>app/code/core/Mage/CatalogSearch/Model/MySQL4/Fulltext.php</strong> bisogna sostituire la riga 342:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>342
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$likeCond</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'('</span> <span style="color: #339933;">.</span> <span style="color: #990000;">join</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' OR '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$like</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">')'</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>con:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>342
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$likeCond</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'('</span> <span style="color: #339933;">.</span> <span style="color: #990000;">join</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' AND '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$like</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">')'</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.magentosolutions.it/blog/2011/04/08/correzione-del-motore-di-ricerca-di-magento-1-4-2.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spostare/Nascondere i link predefiniti di Magento (Account, Login, Cart&#8230;)</title>
		<link>http://www.magentosolutions.it/blog/2010/05/10/spostarenascondere-i-link-predefiniti-di-magento-account-login-cart.html</link>
		<comments>http://www.magentosolutions.it/blog/2010/05/10/spostarenascondere-i-link-predefiniti-di-magento-account-login-cart.html#comments</comments>
		<pubDate>Mon, 10 May 2010 15:43:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Templating]]></category>
		<category><![CDATA[account]]></category>
		<category><![CDATA[cart]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[login]]></category>

		<guid isPermaLink="false">http://www.magentosolutions.it/blog/?p=267</guid>
		<description><![CDATA[Qualche nota su come spostare o nascondere i link predefiniti di Magento.
    * My Account
    * My Wishlist
    * My Cart
    * Checkout
    * Login
]]></description>
			<content:encoded><![CDATA[<p>Può capitare di voler spostare o nascondere i link predefiniti di Magento.</p>
<ul>
<li>My Account</li>
<li>My Wishlist</li>
<li>My Cart</li>
<li>Checkout</li>
<li>Login</li>
</ul>
<p>Questi link sono regolamentati di solito da un blocco chiamato <strong>top.links </strong>definito nel layout page.xml. Il template relativo a questo blocco è il <code>page/template/links.phtml</code>, template che viene dichiarato implicitamente quando un blocco è dichiarato di tipo <code>page/template_links</code> (a questo proposito si veda il metodo <code>_construct()</code> in <code>app/code/core/Mage/Page/Block/Template/Links.php</code>).</p>
<p>I link sono aggiunti al blocco tramite i metodi addLink/addCartLink/addCheckoutLink/addWishlistLink nei seguenti layout:</p>
<ul>
<li>checkout.xml</li>
<li>customer.xml</li>
<li>wishlist.xml</li>
</ul>
<p>Saranno proprio questi i layout da modificare per spostare o nascondere i link dal menu.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentosolutions.it/blog/2010/05/10/spostarenascondere-i-link-predefiniti-di-magento-account-login-cart.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Estendere le categorie aggiungendo un attributo</title>
		<link>http://www.magentosolutions.it/blog/2010/04/23/aggiungere-un-attributo-alle-categorie.html</link>
		<comments>http://www.magentosolutions.it/blog/2010/04/23/aggiungere-un-attributo-alle-categorie.html#comments</comments>
		<pubDate>Fri, 23 Apr 2010 16:36:32 +0000</pubDate>
		<dc:creator>silvia</dc:creator>
				<category><![CDATA[Documentazione]]></category>
		<category><![CDATA[Moduli]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[estensione categorie]]></category>

		<guid isPermaLink="false">http://www.magentosolutions.it/blog/?p=255</guid>
		<description><![CDATA[Un buon tutorial: http://www.magentix.fr/modules-magento/ajouter-categorie-attributs-champs-personnalises.html Se però il campo aggiuntivo deve essere una select popolata dinamicamente, serve qualche ulteriore passo. Il file mysql4-install-0.1.0.php dovrà essere così: 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 startSetup&#40;&#41;; &#160; $installer-&#62;addAttribute&#40;'catalog_category', 'drilldown_link', [...]]]></description>
			<content:encoded><![CDATA[<p>Un buon tutorial:<br />
<a href="http://www.magentix.fr/modules-magento/ajouter-categorie-attributs-champs-personnalises.html">http://www.magentix.fr/modules-magento/ajouter-categorie-attributs-champs-personnalises.html</a></p>
<p>Se però il campo aggiuntivo deve essere una <strong>select popolata dinamicamente</strong>, serve qualche ulteriore passo.<br />
Il file mysql4-install-0.1.0.php dovrà essere così:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">startSetup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$installer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog_category'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'drilldown_link'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
                        <span style="color: #0000ff;">'type'</span>              <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'int'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'backend'</span>           <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'frontend'</span>          <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'label'</span>             <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Attributo collegato (drilldown L2):'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'input'</span>             <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'select'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'class'</span>             <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'source'</span>            <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'bundle/drilldownl2'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'global'</span>            <span style="color: #339933;">=&gt;</span> Mage_Catalog_Model_Resource_Eav_Attribute<span style="color: #339933;">::</span><span style="color: #004000;">SCOPE_GLOBAL</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'visible'</span>           <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'required'</span>          <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'user_defined'</span>      <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'default'</span>           <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'searchable'</span>        <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'filterable'</span>        <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'comparable'</span>        <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'visible_on_front'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'unique'</span>            <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'position'</span>          <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'note'</span>		    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'apply_to'</span>	    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'bundle'</span><span style="color: #339933;">,</span>
                    <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$installer</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">endSetup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Le righe modificate rispetto al tutorial seguito sono:<br />
<code>'input'             =&gt; 'select'<br />
'source'            =&gt; 'bundle/drilldownl2'</code><br />
con la seconda, specifichiamo il <em>model</em> che Magento andrà a cercare per popolare la select.<br />
In altre parole, il sistema si aspetta di trovare questo file:<br />
<code>app/code[/local]/Mage/Bundle/Model/drilldownl2.php</code><br />
che dovrà contenere un metodo <strong>getAllOptions(). </strong><br />
Ecco il codice:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Mage_Bundle_Model_DrilldownL2 <span style="color: #000000; font-weight: bold;">extends</span> Mage_Eav_Model_Entity_Attribute_Source_Abstract
<span style="color: #009900;">&#123;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getAllOptions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_options<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_options <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_options <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
 <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
 <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bundle'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Uno'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'value'</span> <span style="color: #339933;">=&gt;</span>  <span style="color: #cc66cc;">1</span>
 <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
 <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bundle'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Due'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #0000ff;">'value'</span> <span style="color: #339933;">=&gt;</span>  <span style="color: #cc66cc;">0</span>
 <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_options<span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.magentosolutions.it/blog/2010/04/23/aggiungere-un-attributo-alle-categorie.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple Tablerates: installazione e configurazione</title>
		<link>http://www.magentosolutions.it/blog/2010/04/23/multiple-tablerates-installazione-e-configurazione.html</link>
		<comments>http://www.magentosolutions.it/blog/2010/04/23/multiple-tablerates-installazione-e-configurazione.html#comments</comments>
		<pubDate>Fri, 23 Apr 2010 15:31:07 +0000</pubDate>
		<dc:creator>silvia</dc:creator>
				<category><![CDATA[Documentazione]]></category>
		<category><![CDATA[Moduli]]></category>
		<category><![CDATA[multiple tablerates]]></category>
		<category><![CDATA[shipping methods]]></category>

		<guid isPermaLink="false">http://www.magentosolutions.it/blog/?p=248</guid>
		<description><![CDATA[Utile estensione che permette di impostare differenti metodi di spedizione basati su differenti regole: paese di provenienza del cliente, prezzo/quantità/peso dell&#8217; ordine&#8230;. L&#8217;estensione si installa via MagentoConnect da qui: http://www.magentocommerce.com/magento-connect/Yarhajile/extension/728/multiple-tablerates (se MagentoConnect non riuscisse a scaricare i files, ecco il link diretto: http://connect.magentocommerce.com/community/get/Pw_Multipletablerates-0.2.2.tgz ) Un tutorial utile per la configurazione: http://webshop-conversion.com/2009/06/27/importing-and-exporting-table-rates-in-magento/ Ecco i passaggi: 1)   [...]]]></description>
			<content:encoded><![CDATA[<p>Utile estensione che permette di impostare differenti metodi di spedizione basati su differenti regole: paese di provenienza del cliente, prezzo/quantità/peso dell&#8217; ordine&#8230;.</p>
<p>L&#8217;estensione si installa via MagentoConnect da qui:<br />
<a href="http://www.magentocommerce.com/magento-connect/Yarhajile/extension/728/multiple-tablerates">http://www.magentocommerce.com/magento-connect/Yarhajile/extension/728/multiple-tablerates</a></p>
<p>(se MagentoConnect non riuscisse a scaricare i files, ecco il link diretto:<br />
<a href="http://connect.magentocommerce.com/community/get/Pw_Multipletablerates-0.2.2.tgz">http://connect.magentocommerce.com/community/get/Pw_Multipletablerates-0.2.2.tgz</a> )</p>
<p>Un tutorial utile per la configurazione:<br />
<a href="http://webshop-conversion.com/2009/06/27/importing-and-exporting-table-rates-in-magento/">http://webshop-conversion.com/2009/06/27/importing-and-exporting-table-rates-in-magento/</a></p>
<p>Ecco i passaggi:</p>
<p>1)   System -&gt; Configuration -&gt; Shipping Methods</p>
<p>2)  scegliere Multiple Tablerates:<br />
sono visibili le opzioni di configurazione generali, ma non la funzione import/export CSV</p>
<p>3)  scegliere il <strong>website </strong>dalla tendina in alto a sinistra:<br />
a questo punto compaiono i pusanti Import e Export.</p>
<p>Le regole vengono definite nel file CSV che poi bisogna importare. La sintassi è spiegata qui:<br />
<a href="http://www.magentocommerce.com/boards/viewthread/26751/">http://www.magentocommerce.com/boards/viewthread/26751/</a><em><br />
&#8220;Country,Region/State,Zip/Postal Code,Condition Value,Shipping  Price,method Code,Method Name,Method Description,Condition Type&#8221;</em></p>
<p>4)  dopo aver costruito correttamente il CSV, eseguire l&#8217;import e cancellare la cache.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.magentosolutions.it/blog/2010/04/23/multiple-tablerates-installazione-e-configurazione.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Correzione del modulo SimpleConfigurableProducts</title>
		<link>http://www.magentosolutions.it/blog/2010/02/01/correzione-del-modulo-simpleconfigurableproducts.html</link>
		<comments>http://www.magentosolutions.it/blog/2010/02/01/correzione-del-modulo-simpleconfigurableproducts.html#comments</comments>
		<pubDate>Mon, 01 Feb 2010 11:31:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Moduli]]></category>
		<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Snippet]]></category>
		<category><![CDATA[Prezzi]]></category>
		<category><![CDATA[Prodotti configurabili]]></category>

		<guid isPermaLink="false">http://www.magentosolutions.it/blog/?p=239</guid>
		<description><![CDATA[In Magento il prezzo dei prodotti semplici collegati a un configurabile viene calcolato come differenza dal prezzo del prodotto configurabile. Per ovviare a questo problema e poter impostare direttamente il prezzo del prodotto semplice, è disponibile su MagentoConnect il modulo SimpleConfigurableProducts di OrganicInternet. Purtroppo tale modulo è affetto da un bug per cui, quando un [...]]]></description>
			<content:encoded><![CDATA[<p>In Magento il prezzo dei prodotti semplici collegati a un configurabile viene calcolato come differenza dal prezzo del prodotto configurabile.<br />
Per ovviare a questo problema e poter impostare direttamente il prezzo del prodotto semplice, è disponibile su MagentoConnect il modulo <a href="http://www.magentocommerce.com/extension/596/simple-configurable-products">SimpleConfigurableProducts</a> di OrganicInternet.</p>
<p>Purtroppo tale modulo è affetto da un bug per cui, quando un prodotto viene inserito nel carrello, non vengono visualizzate le opzioni configurabili che sono state selezionate. Tale comportamento è dovuto al fatto che quando SimpleConfigurableProducts è attivo, nel carrello non viene inserito il prodotto configurabile con le sue opzioni, ma viene inserito direttamente il prodotto semplice.</p>
<p>Riportiamo di seguito la correzione del bug.<br />
Il file che va modificato è <code>app/code/community/OrganicInternet/SimpleConfigurableProducts/Checkout/Block/Cart/Item</code>. Bisogna aggiungere alla fine del file la funzione <code>getProductOptions()</code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getProductOptions<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$parent</span><span style="color: #339933;">=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getConfigurableProductParent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000088;">$attributes</span><span style="color: #339933;">=</span><span style="color: #000088;">$parent</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getTypeInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getConfigurableAttributes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$attribute</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$attribute_id</span><span style="color: #339933;">=</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProductAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$attribute_code</span><span style="color: #339933;">=</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProductAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttributeCode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$childProduct</span><span style="color: #339933;">=</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog/product'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProduct</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
         <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getProductAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFrontend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
         <span style="color: #0000ff;">'value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$childProduct</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttributeText</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attribute_code</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
         <span style="color: #0000ff;">'print_value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$childProduct</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAttributeText</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attribute_code</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
         <span style="color: #0000ff;">'option_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$attribute_id</span><span style="color: #339933;">,</span>
         <span style="color: #0000ff;">'option_type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
         <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>      
&nbsp;
   <span style="color: #b1b100;">return</span> <span style="color: #000088;">$options</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.magentosolutions.it/blog/2010/02/01/correzione-del-modulo-simpleconfigurableproducts.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ordinamento delle categorie</title>
		<link>http://www.magentosolutions.it/blog/2010/01/25/ordinamento-delle-categorie.html</link>
		<comments>http://www.magentosolutions.it/blog/2010/01/25/ordinamento-delle-categorie.html#comments</comments>
		<pubDate>Mon, 25 Jan 2010 16:49:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Senza categoria]]></category>
		<category><![CDATA[Snippet]]></category>
		<category><![CDATA[categorie]]></category>
		<category><![CDATA[Importazione]]></category>
		<category><![CDATA[Ordinamento]]></category>

		<guid isPermaLink="false">http://www.magentosolutions.it/blog/?p=232</guid>
		<description><![CDATA[Utilizzando i vari moduli che ci sono in rete per importare prodotti e categorie da csv, non è previsto un modo per imporre l&#8217;ordinamento alle categorie importare. Riportiamo di seguito uno script da eseguire a importazione avvenuta. La funzione ricorsiva orderCategories riordina ordina tutto l&#8217;albero delle categorie avente radice nella categoria con id $cat_id &#60; [...]]]></description>
			<content:encoded><![CDATA[<p>Utilizzando i vari moduli che ci sono in rete per importare <a href="http://www.magentocommerce.com/boards/viewthread/35865/">prodotti e categorie</a> da csv, non è previsto un modo per imporre l&#8217;ordinamento alle categorie importare.</p>
<p>Riportiamo di seguito uno script da eseguire a importazione avvenuta. La funzione ricorsiva <code>orderCategories</code> riordina ordina tutto l&#8217;albero delle categorie avente radice nella categoria con id <code>$cat_id</code></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">function</span> orderCategories<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cat_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$collection</span><span style="color: #339933;">=</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalog/category'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span> <span style="color: #004000;">getCollection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addAttributeToFilter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'parent_id'</span><span style="color: #339933;">,</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;like&quot;</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$cat_id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addAttributeToSelect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'url_path'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOrder</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'asc'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$collection</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$collection</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setPosition</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$category_id</span><span style="color: #339933;">=</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">print</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;. &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #990000;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
            orderCategories<span style="color: #009900;">&#40;</span><span style="color: #000088;">$category_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Per riordinare tutte le categorie del website e dello store di default basta estrarre la Root Category Id</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'app/Mage.php'</span><span style="color: #339933;">;</span>
Mage<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCurrentStore</span><span style="color: #009900;">&#40;</span>Mage_Core_Model_App<span style="color: #339933;">::</span><span style="color: #004000;">ADMIN_STORE_ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$website</span><span style="color: #339933;">=</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getWebsite</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$store</span><span style="color: #339933;">=</span><span style="color: #000088;">$website</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDefaultStore</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$category_id</span><span style="color: #339933;">=</span><span style="color: #000088;">$store</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRootCategoryId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
orderCategories<span style="color: #009900;">&#40;</span><span style="color: #000088;">$category_id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.magentosolutions.it/blog/2010/01/25/ordinamento-delle-categorie.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Promozioni: come recuperare il tasso di sconto nel template</title>
		<link>http://www.magentosolutions.it/blog/2010/01/11/promozioni-come-recuperare-il-tasso-di-sconto-nel-template.html</link>
		<comments>http://www.magentosolutions.it/blog/2010/01/11/promozioni-come-recuperare-il-tasso-di-sconto-nel-template.html#comments</comments>
		<pubDate>Mon, 11 Jan 2010 16:38:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Moduli]]></category>
		<category><![CDATA[Snippet]]></category>
		<category><![CDATA[Promozioni]]></category>
		<category><![CDATA[Sconti]]></category>

		<guid isPermaLink="false">http://www.magentosolutions.it/blog/?p=171</guid>
		<description><![CDATA[Nel comportamento standard di magento, eventuali prezzi scontati definiti nella sezione &#8220;Promotions&#8221; sono visualizzati solo ai clienti che ne hanno diritto. Tuttavia in certi casi può essere utile poter mostrare i prezzi scontati a tutti gli utenti: un esempio potrebbe essere quello di mostrare i vantaggi dell&#8217;iscrizione al sito. La visualizzazione dei prezzi scontati si [...]]]></description>
			<content:encoded><![CDATA[<p>Nel comportamento standard di magento, eventuali prezzi scontati definiti nella sezione &#8220;Promotions&#8221; sono visualizzati solo ai clienti che ne hanno diritto. Tuttavia in certi casi può essere utile poter mostrare i prezzi scontati a tutti gli utenti: un esempio potrebbe essere quello di mostrare i vantaggi dell&#8217;iscrizione al sito.</p>
<p>La visualizzazione dei prezzi scontati si può aggiungere modificando il template <code>/app/design/frontend/default/{template_name}/template/catalog/product/price.phtml</code></p>
<p>Innanzitutto recuperiamo l&#8217;array di tutti i tassi di sconto:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$rules</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'catalogrule/rule'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCollection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
             <span style="color: #339933;">-&gt;</span><span style="color: #004000;">addFieldToFilter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'is_active'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$discount_amount</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rules</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$rule</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span><span style="color: #000088;">$discount_amount</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$rule</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDiscountAmount</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>Supponendo che lo sconto che vogliamo pubblicizzare sia in <code>$discount_amount[0]</code>, la visualizzazione del prezzo scontato si può ottenere aggiungendo sotto a</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">		&lt;span class=&quot;regular-price&quot; id=&quot;product-price-<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$_id</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getIdSuffix</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currency</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_price</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/span&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>il seguente codice:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'customer/session'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isLoggedIn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;p class=&quot;special-price&quot;&gt;
	&lt;span class=&quot;price-label&quot; id=&quot;registered-price-label<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getIdSuffix</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
	<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Registered Price:'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/span&gt;
	&lt;span class=&quot;price&quot; id=&quot;registered-product-price-<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$_id</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getIdSuffix</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'core'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">currency</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_finalPrice</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span><span style="color: #000088;">$discount_amount</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
	&lt;/span&gt;
&lt;/p&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.magentosolutions.it/blog/2010/01/11/promozioni-come-recuperare-il-tasso-di-sconto-nel-template.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eseguire in batch un profilo di importazione</title>
		<link>http://www.magentosolutions.it/blog/2010/01/11/eseguire-in-batch-un-profilo-di-importazione.html</link>
		<comments>http://www.magentosolutions.it/blog/2010/01/11/eseguire-in-batch-un-profilo-di-importazione.html#comments</comments>
		<pubDate>Mon, 11 Jan 2010 12:05:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programmazione]]></category>
		<category><![CDATA[Batch]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[Import]]></category>
		<category><![CDATA[Importazione]]></category>
		<category><![CDATA[Profili]]></category>

		<guid isPermaLink="false">http://www.magentosolutions.it/blog/?p=154</guid>
		<description><![CDATA[Di default i profili di importazione di magento presuppongono una stretta interazione tra client e server. I dati in ingresso sono processati tramite un ciclo in javascript e l&#8217;importazione viene effettuata tramite chiamate AJAX. Questo approccio presenta diverse problematiche, prima fra tutte la possibilità che, per problemi di rete tra client e server, l&#8217;operazione di [...]]]></description>
			<content:encoded><![CDATA[<p>Di default i profili di importazione di magento presuppongono una stretta interazione tra client e server. I dati in ingresso sono processati tramite un ciclo in javascript e l&#8217;importazione viene effettuata tramite chiamate AJAX.<br />
Questo approccio presenta diverse problematiche, prima fra tutte la possibilità che, per problemi di rete tra client e server, l&#8217;operazione di importazione non arrivi a completamento. </p>
<p>Una possibile soluzione è ricreare in uno script esterno a Magento tutte le chiamate al controller effettuando il ciclo direttamente in php. Il controller deputato a gestire gli script di importazione è <code>Mage_Adminhtml_System_Convert_ProfileController</code>.<br />
<span id="more-154"></span></p>
<p>Per fare uno script esterno a magento che utilizzi le funzioni magento bisogna ricreare il contesto. Questa operazione è effettuata tramite:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'app/Mage.php'</span><span style="color: #339933;">;</span>
&nbsp;
Mage<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCurrentStore</span><span style="color: #009900;">&#40;</span>Mage_Core_Model_App<span style="color: #339933;">::</span><span style="color: #004000;">ADMIN_STORE_ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Bisogna fare molta attenzione soprattutto all&#8217;istruzione presente alla riga 3: in molti script che presenti in rete al suo posto si trova spesso un semplice <code>Mage::app();</code>. Non sono la stessa cosa! Un possibile problema introdotto dall&#8217;utilizzo di un semplice <code>Mage->app();</code> è che, al momento in cui si carica un prodotto, l&#8217;oggetto non viene caricato completamente (la variabile <code>_origData</code> viene impostata a null) e di conseguenza le operazioni di update non vengono eseguite correttamente.</p>
<p>Il nome del file in cui sono contenuti i dati da importare e il l&#8217;id del profilo di importazione sono passati in get.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$profileId</span> <span style="color: #339933;">=</span>  Mage<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'profile_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'files'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;No file has been set!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Ultimo passaggio della fase di ricreazione del contesto è l&#8217;inizializzazione delle sessioni magento.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$userModel</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin/user'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$userModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setUserId</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setUser</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$userModel</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Dato che il nostro script verrà eseguito in background, i messaggi di notifica dello stato di avanzamento delle operazioni vengono inviati a un file di log piuttosto che a schermo (come invece fanno normalmente gli script di importazione). Il codice che segue serve a inizializzare il log (si ricorda che il log deve essere <emph>abilitato da backend</emph> andando su System -> Configuration -> Developer -> Log Settings e imponendo Enabled a &#8220;Yes&#8221;).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$logFileName</span><span style="color: #339933;">=</span> <span style="color: #000088;">$filename</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.log'</span><span style="color: #339933;">;</span>  
<span style="color: #000088;">$recordCount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #990000;">umask</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Inizio dell'importazione di &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Nel momento in cui da backend si lancia uno script di importazione viene lanciato il metodo <code>runAction()</code> che a sua volta lancia tutte le operazioni di inizializzazione del profilo tramite <code>_initProfile()</code>. Riportiamo nel nostro script tali operazioni.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$profile</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dataflow/profile'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$profileId</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$profile</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$profileId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$profile</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addError</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'The profile you are trying to save no longer exists'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
Mage<span style="color: #339933;">::</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'current_convert_profile'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$profile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>A questo punto l&#8217;esecuzione normale del profilo prevede la renderizzazione tramite toHtml() di <code>Mage_Adminhtml_Block_System_Convert_Profile_Run</code>. Come già accennato l&#8217;esecuzione del profilo viene effettuata tramite chiamate AJAX Eliminando tutto il codice che serve alla creazione della pagina HTML, nel nostro script viene mantenuto esclusivamente il codice che manda in esecuzione il profilo. In particolare il codice che importa effettivamente le righe è contenuto nella funzione <code>batchRunAction()</code> del controller <code>Mage_Adminhtml_System_Convert_ProfileController</code>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$profile</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$batchModel</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dataflow/batch'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAdapter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$batchId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        <span style="color: #000088;">$batchImportModel</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBatchImportModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$importIds</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$batchImportModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getIdCollection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
        <span style="color: #000088;">$batchModel</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dataflow/batch'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$batchId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      
        <span style="color: #000088;">$adapter</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAdapter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$adapter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBatchParams</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParams</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$importIds</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$importId</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$recordCount</span><span style="color: #339933;">++;</span>
            try <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$batchImportModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$batchImportModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$errors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dataflow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Skip undefined row'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000088;">$importData</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$batchImportModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBatchData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                try <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$adapter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveRow</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>          
                    <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$recordCount</span><span style="color: #339933;">%</span><span style="color:#800080;">10</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$recordCount</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' - Completed!! '</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span> catch<span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$ex</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Record# '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$recordCount</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' - SKU = '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">' - Error - '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ex</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>        
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$profile</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExceptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>          
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Importazione di <span style="color: #006699; font-weight: bold;">$filename</span> completata: <span style="color: #006699; font-weight: bold;">$recordCount</span> record inseriti&quot;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Per avere il controllo sull&#8217;avanzamento del processo si è scelto di scrivere un record nel file di log ogni 10 prodotti importati (vedi righe 53-55).</p>
<p>Lo script risultante è:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'app/Mage.php'</span><span style="color: #339933;">;</span>
&nbsp;
Mage<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCurrentStore</span><span style="color: #009900;">&#40;</span>Mage_Core_Model_App<span style="color: #339933;">::</span><span style="color: #004000;">ADMIN_STORE_ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$profileId</span> <span style="color: #339933;">=</span>  Mage<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'profile_id'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">app</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'files'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;No file has been set!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$userModel</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin/user'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$userModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setUserId</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setUser</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$userModel</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$logFileName</span><span style="color: #339933;">=</span> <span style="color: #000088;">$filename</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.log'</span><span style="color: #339933;">;</span>  
<span style="color: #000088;">$recordCount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #990000;">umask</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Inizio dell'importazione di &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$filename</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
<span style="color: #000088;">$profile</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dataflow/profile'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$profileId</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$profile</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$profileId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$profile</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'adminhtml/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addError</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'The profile you are trying to save no longer exists'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
Mage<span style="color: #339933;">::</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'current_convert_profile'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$profile</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$profile</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$batchModel</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getSingleton</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dataflow/batch'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAdapter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$batchId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        <span style="color: #000088;">$batchImportModel</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBatchImportModel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$importIds</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$batchImportModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getIdCollection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
        <span style="color: #000088;">$batchModel</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dataflow/batch'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$batchId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      
        <span style="color: #000088;">$adapter</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">getModel</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAdapter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$adapter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setBatchParams</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$batchModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParams</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$importIds</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$importId</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$recordCount</span><span style="color: #339933;">++;</span>
            try <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$batchImportModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importId</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$batchImportModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$errors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> Mage<span style="color: #339933;">::</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'dataflow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Skip undefined row'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000088;">$importData</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$batchImportModel</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getBatchData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                try <span style="color: #009900;">&#123;</span>
                    <span style="color: #000088;">$adapter</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">saveRow</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$importData</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>          
                    <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$recordCount</span><span style="color: #339933;">%</span><span style="color:#800080;">10</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$recordCount</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' - Completed!! '</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span> catch<span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$ex</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Record# '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$recordCount</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' - SKU = '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$importData</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sku'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">' - Error - '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ex</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>        
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$profile</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getExceptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>          
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
Mage<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Importazione di <span style="color: #006699; font-weight: bold;">$filename</span> completata: <span style="color: #006699; font-weight: bold;">$recordCount</span> record inseriti&quot;</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span><span style="color: #000088;">$logFileName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.magentosolutions.it/blog/2010/01/11/eseguire-in-batch-un-profilo-di-importazione.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

