<?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>Lapiz Corto &#187; Cambiar Conjunto Producto</title>
	<atom:link href="http://www.lapizcorto.com/tag/cambiar-conjunto-producto/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lapizcorto.com</link>
	<description>Para esas soluciones que nunca recuerdas</description>
	<lastBuildDate>Mon, 14 Dec 2015 08:34:34 +0000</lastBuildDate>
	<language>es-ES</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
	<item>
		<title>Como cambiar el conjunto de atributos de Magento</title>
		<link>http://www.lapizcorto.com/como-cambiar-el-conjunto-de-atributos-de-magento/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=como-cambiar-el-conjunto-de-atributos-de-magento</link>
		<comments>http://www.lapizcorto.com/como-cambiar-el-conjunto-de-atributos-de-magento/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 23:03:46 +0000</pubDate>
		<dc:creator><![CDATA[Jorge]]></dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[Cambiar Conjunto Producto]]></category>
		<category><![CDATA[Conjunto de Atributos]]></category>

		<guid isPermaLink="false">http://www.lapizcorto.com/?p=497</guid>
		<description><![CDATA[Por defecto en Magento no se puede cambiar el conjunto de atributos asignados a un producto, pero con muy poquito esfuerzo podemos conseguirlo. Para esto tendremos que tocar el core de Magento por lo que siempre es recomendable hacer una copia en code/local para no tener problema con las actualizaciones. En primer lugar tendremos que [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Por defecto en Magento no se puede cambiar el conjunto de atributos asignados a un producto, pero con muy poquito esfuerzo podemos conseguirlo.</p>
<p>Para esto tendremos que tocar el core de Magento por lo que siempre es recomendable hacer una copia en code/local para no tener problema con las actualizaciones.</p>
<p>En primer lugar tendremos que cambiar el fichero app/code/core/Mage/Adminhtml/Block/Catalog/Product/Grid.php y sobre la linea 253 añadir</p>
<pre class="brush: plain; title: ; notranslate">
 $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
    -&gt;setEntityTypeFilter(Mage::getModel('catalog/product')
    -&gt;getResource()-&gt;getTypeId())-&gt;load()-&gt;toOptionHash();

    array_unshift($statuses, array('label'=&gt;'', 'value'=&gt;''));
    $this-&gt;getMassactionBlock()-&gt;addItem('attribute_set', array(
    'label'=&gt; Mage::helper('catalog')-&gt;__('Change attribute set'),
    'url' =&gt; $this-&gt;getUrl('*/*/massAttributeSet', array('_current'=&gt;true)),
    'additional' =&gt; array(
    'visibility' =&gt; array(
    'name' =&gt; 'attribute_set',
    'type' =&gt; 'select',
    'class' =&gt; 'required-entry',
    'label' =&gt; Mage::helper('catalog')-&gt;__('Attribute Set'),
    'values' =&gt; $sets
    )
    )
    ));
</pre>
<p>Luego en app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php añadimos esta nueva función</p>
<pre class="brush: plain; title: ; notranslate">
  public function massAttributeSetAction(){
    
    	$productIds = $this-&gt;getRequest()-&gt;getParam('product');
    	$storeId = (int)$this-&gt;getRequest()-&gt;getParam(‘store’, 0);
    	if(!is_array($productIds)) {
    		$this-&gt;_getSession()-&gt;addError($this-&gt;__('Please select product(s)'));
    	} else {
    		try {
    			foreach ($productIds as $productId) {
    				$product = Mage::getSingleton('catalog/product')
    				-&gt;unsetData()
    				-&gt;setStoreId($storeId)
    				-&gt;load($productId)
    				-&gt;setAttributeSetId($this-&gt;getRequest()-&gt;getParam('attribute_set'))
    				-&gt;setIsMassupdate(true)
    				-&gt;save();
    			}
    			Mage::dispatchEvent('catalog_product_massupdate_after', array('products'=&gt;$productIds));
    			$this-&gt;_getSession()-&gt;addSuccess(
    			$this-&gt;__('Total of %d record(s) were successfully updated', count($productIds)));
    		} catch (Exception $e) {
    			$this-&gt;_getSession()-&gt;addError($e-&gt;getMessage());
    		}
    	}
    
    	$this-&gt;_redirect('*/*/', array('store'=&gt;(int)$this-&gt;getRequest()-&gt;getParam('store', 0)));
    }
</pre>
<p>Con esto ya podemos acceder a los productos y desde la rejilla principal podremos cambiar el conjunto de atributos.</p>
<p>[/sourcecode]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lapizcorto.com/como-cambiar-el-conjunto-de-atributos-de-magento/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
