<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Magento: Import Multiple Images or Remove Images durring Batch Import</title>
	<atom:link href="http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/</link>
	<description>Just another Sharpdot weblog</description>
	<lastBuildDate>Mon, 09 Jan 2012 12:32:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Karr</title>
		<link>http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/comment-page-1/#comment-1810</link>
		<dc:creator>Karr</dc:creator>
		<pubDate>Tue, 23 Aug 2011 20:19:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.sharpdotinc.com/mdost/?p=179#comment-1810</guid>
		<description>Ha, worked like a charm! 

If I was to place the code into the right place - it would have worked yesterday :) Human error is the cause to my misery :) 

Thanks Mike!!!</description>
		<content:encoded><![CDATA[<p>Ha, worked like a charm! </p>
<p>If I was to place the code into the right place &#8211; it would have worked yesterday <img src='http://www.sharpdotinc.com/mdost/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Human error is the cause to my misery <img src='http://www.sharpdotinc.com/mdost/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
<p>Thanks Mike!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike D</title>
		<link>http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/comment-page-1/#comment-1809</link>
		<dc:creator>Mike D</dc:creator>
		<pubDate>Tue, 23 Aug 2011 19:52:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.sharpdotinc.com/mdost/?p=179#comment-1809</guid>
		<description>Ok, So now we know we are getting into the if statement that should remove the images related to the product.

Now do the following:
1. remove any lines that we added for the die() statements. so that it will not die.

2. clear the reports and logs. delete everything in /var/report and var/logs

3. Make sure that logging is enabled. This is in the config settings. Admin -&gt; System -&gt; configuration -&gt; Developer -&gt; Then you should see log setting in one of the field sets. Make sure logging is enabled.

4. Now run the import again. When it is finished see if any logs or reports were created. The logs should tell what/why the code is not working.</description>
		<content:encoded><![CDATA[<p>Ok, So now we know we are getting into the if statement that should remove the images related to the product.</p>
<p>Now do the following:<br />
1. remove any lines that we added for the die() statements. so that it will not die.</p>
<p>2. clear the reports and logs. delete everything in /var/report and var/logs</p>
<p>3. Make sure that logging is enabled. This is in the config settings. Admin -&gt; System -&gt; configuration -&gt; Developer -&gt; Then you should see log setting in one of the field sets. Make sure logging is enabled.</p>
<p>4. Now run the import again. When it is finished see if any logs or reports were created. The logs should tell what/why the code is not working.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karr</title>
		<link>http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/comment-page-1/#comment-1808</link>
		<dc:creator>Karr</dc:creator>
		<pubDate>Tue, 23 Aug 2011 19:47:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.sharpdotinc.com/mdost/?p=179#comment-1808</guid>
		<description>Got the &#039;Now we are here&#039; note!</description>
		<content:encoded><![CDATA[<p>Got the &#8216;Now we are here&#8217; note!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike D</title>
		<link>http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/comment-page-1/#comment-1807</link>
		<dc:creator>Mike D</dc:creator>
		<pubDate>Tue, 23 Aug 2011 19:32:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.sharpdotinc.com/mdost/?p=179#comment-1807</guid>
		<description>Ok, so now remove. Since we know we are getting here now.
&lt;code&gt;
print_r($importData[&#039;remove_all_images&#039;]);die(&quot;Remove Images Value&quot;);
&lt;/code&gt;

and change the die two lines below that to 
&lt;code&gt;
print_r(&quot;Now we are here&quot;);die();
&lt;code&gt;

and run the import again, and see if you get the red box that says &quot;Now we are here&quot;</description>
		<content:encoded><![CDATA[<p>Ok, so now remove. Since we know we are getting here now.<br />
<code><br />
print_r($importData['remove_all_images']);die("Remove Images Value");<br />
</code></p>
<p>and change the die two lines below that to<br />
<code><br />
print_r("Now we are here");die();<br />
</code><code></p>
<p>and run the import again, and see if you get the red box that says "Now we are here"</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karr</title>
		<link>http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/comment-page-1/#comment-1806</link>
		<dc:creator>Karr</dc:creator>
		<pubDate>Tue, 23 Aug 2011 19:27:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.sharpdotinc.com/mdost/?p=179#comment-1806</guid>
		<description>I import via: import/export - dataflow-profiles - import all products

Here is the code (the one that finally gave me red error)

&lt;code&gt;  foreach ($product-&gt;getMediaAttributes() as $mediaAttributeCode =&gt; $mediaAttribute) {
            $addedFile = &#039;&#039;;
            if (isset($importData[$mediaAttributeCode . &#039;_label&#039;])) {
                $fileLabel = trim($importData[$mediaAttributeCode . &#039;_label&#039;]);
                if (isset($importData[$mediaAttributeCode])) {
                    $keyInAddedFile = array_search($importData[$mediaAttributeCode],
                        $addedFilesCorrespondence[&#039;alreadyAddedFiles&#039;]);
                    if ($keyInAddedFile !== false) {
                        $addedFile = $addedFilesCorrespondence[&#039;alreadyAddedFilesNames&#039;][$keyInAddedFile];
                    }
                }

                if (!$addedFile) {
                    $addedFile = $product-&gt;getData($mediaAttributeCode);
                }
                if ($fileLabel &amp;&amp; $addedFile) {
                    $mediaGalleryBackendModel-&gt;updateImage($product, $addedFile, array(&#039;label&#039; =&gt; $fileLabel));
                }
            }
			
			//MRD added to remove all images for product before uploading new images
    print_r($importData[&#039;remove_all_images&#039;]);die(&quot;Remove Images Value&quot;);
	if(isset($importData[&#039;remove_all_images&#039;]) &amp;&amp; $importData[&#039;remove_all_images&#039;]==&quot;yes&quot; ){
     die();
	 //check if gallery attribute exists then remove all images if it exists
      //Get products gallery attribute
      $attributes = $product-&gt;getTypeInstance()-&gt;getSetAttributes();
     	if (isset($attributes[&#039;media_gallery&#039;])) {
	$gallery = $attributes[&#039;media_gallery&#039;];
	//Get the images
	$galleryData = $product-&gt;getMediaGallery();
	foreach($galleryData[&#039;images&#039;] as $image){
	//If image exists
    	
		
		if ($gallery-&gt;getBackend()-&gt;getImage($product, $image[&#039;file&#039;])) {
            $gallery-&gt;getBackend()-&gt;removeImage($product, $image[&#039;file&#039;]);
        }
	}
}
$gallery-&gt;clearMediaAttribute($product, array(&#039;image&#039;,&#039;small_image&#039;,&#039;thumbnail&#039;));
     }
	 
	 
     //END Remove Images
        }

        $product-&gt;setIsMassupdate(true);
        $product-&gt;setExcludeUrlRewrite(true);

        $product-&gt;save();

        return true;
		
    }&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>I import via: import/export &#8211; dataflow-profiles &#8211; import all products</p>
<p>Here is the code (the one that finally gave me red error)</p>
<p><code>  foreach ($product-&gt;getMediaAttributes() as $mediaAttributeCode =&gt; $mediaAttribute) {<br />
            $addedFile = '';<br />
            if (isset($importData[$mediaAttributeCode . '_label'])) {<br />
                $fileLabel = trim($importData[$mediaAttributeCode . '_label']);<br />
                if (isset($importData[$mediaAttributeCode])) {<br />
                    $keyInAddedFile = array_search($importData[$mediaAttributeCode],<br />
                        $addedFilesCorrespondence['alreadyAddedFiles']);<br />
                    if ($keyInAddedFile !== false) {<br />
                        $addedFile = $addedFilesCorrespondence['alreadyAddedFilesNames'][$keyInAddedFile];<br />
                    }<br />
                }</p>
<p>                if (!$addedFile) {<br />
                    $addedFile = $product-&gt;getData($mediaAttributeCode);<br />
                }<br />
                if ($fileLabel &amp;&amp; $addedFile) {<br />
                    $mediaGalleryBackendModel-&gt;updateImage($product, $addedFile, array('label' =&gt; $fileLabel));<br />
                }<br />
            }</p>
<p>			//MRD added to remove all images for product before uploading new images<br />
    print_r($importData['remove_all_images']);die("Remove Images Value");<br />
	if(isset($importData['remove_all_images']) &amp;&amp; $importData['remove_all_images']=="yes" ){<br />
     die();<br />
	 //check if gallery attribute exists then remove all images if it exists<br />
      //Get products gallery attribute<br />
      $attributes = $product-&gt;getTypeInstance()-&gt;getSetAttributes();<br />
     	if (isset($attributes['media_gallery'])) {<br />
	$gallery = $attributes['media_gallery'];<br />
	//Get the images<br />
	$galleryData = $product-&gt;getMediaGallery();<br />
	foreach($galleryData['images'] as $image){<br />
	//If image exists</p>
<p>		if ($gallery-&gt;getBackend()-&gt;getImage($product, $image['file'])) {<br />
            $gallery-&gt;getBackend()-&gt;removeImage($product, $image['file']);<br />
        }<br />
	}<br />
}<br />
$gallery-&gt;clearMediaAttribute($product, array('image','small_image','thumbnail'));<br />
     }</p>
<p>     //END Remove Images<br />
        }</p>
<p>        $product-&gt;setIsMassupdate(true);<br />
        $product-&gt;setExcludeUrlRewrite(true);</p>
<p>        $product-&gt;save();</p>
<p>        return true;</p>
<p>    }</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike D</title>
		<link>http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/comment-page-1/#comment-1805</link>
		<dc:creator>Mike D</dc:creator>
		<pubDate>Tue, 23 Aug 2011 19:21:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.sharpdotinc.com/mdost/?p=179#comment-1805</guid>
		<description>Seems like the file is not being used. 

Just to make sure we are on the same page,
1. please post a few lines of the code you changed just changed, so I can make sure that you changed it in the right spot.

2. IN magento 1.5 there are actually a few spots you can import/export from. Please list exactly where you go to import(in the admin).</description>
		<content:encoded><![CDATA[<p>Seems like the file is not being used. </p>
<p>Just to make sure we are on the same page,<br />
1. please post a few lines of the code you changed just changed, so I can make sure that you changed it in the right spot.</p>
<p>2. IN magento 1.5 there are actually a few spots you can import/export from. Please list exactly where you go to import(in the admin).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karr</title>
		<link>http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/comment-page-1/#comment-1804</link>
		<dc:creator>Karr</dc:creator>
		<pubDate>Tue, 23 Aug 2011 19:21:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.sharpdotinc.com/mdost/?p=179#comment-1804</guid>
		<description>I moved the code lower and It just displayed 

yesRemove Images Value in red error box!</description>
		<content:encoded><![CDATA[<p>I moved the code lower and It just displayed </p>
<p>yesRemove Images Value in red error box!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karr</title>
		<link>http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/comment-page-1/#comment-1803</link>
		<dc:creator>Karr</dc:creator>
		<pubDate>Tue, 23 Aug 2011 18:48:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.sharpdotinc.com/mdost/?p=179#comment-1803</guid>
		<description>Nope, everything went the way it would if everything was fine. No errors. What does it mean?</description>
		<content:encoded><![CDATA[<p>Nope, everything went the way it would if everything was fine. No errors. What does it mean?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike D</title>
		<link>http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/comment-page-1/#comment-1802</link>
		<dc:creator>Mike D</dc:creator>
		<pubDate>Tue, 23 Aug 2011 18:32:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.sharpdotinc.com/mdost/?p=179#comment-1802</guid>
		<description>Add this  line 
&lt;code&gt;
print_r($importData[&#039;remove_all_images&#039;]);die(&quot;Remove Images Value&quot;);
&lt;/code&gt;

just above this line
&lt;code&gt;
if(isset($importData[&#039;remove_all_images&#039;]) &amp;&amp; $importData[&#039;remove_all_images&#039;]==&quot;yes&quot; ){
&lt;/code&gt;


ANd let me know what it displayes when you run the import. It should be displayed in a red errors box</description>
		<content:encoded><![CDATA[<p>Add this  line<br />
<code><br />
print_r($importData['remove_all_images']);die("Remove Images Value");<br />
</code></p>
<p>just above this line<br />
<code><br />
if(isset($importData['remove_all_images']) &amp;&amp; $importData['remove_all_images']=="yes" ){<br />
</code></p>
<p>ANd let me know what it displayes when you run the import. It should be displayed in a red errors box</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karr</title>
		<link>http://www.sharpdotinc.com/mdost/2010/03/02/magento-import-multiple-images-or-remove-images-durring-batch-import/comment-page-1/#comment-1801</link>
		<dc:creator>Karr</dc:creator>
		<pubDate>Tue, 23 Aug 2011 18:29:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.sharpdotinc.com/mdost/?p=179#comment-1801</guid>
		<description>remove_all_images value is &#039;yes&#039;</description>
		<content:encoded><![CDATA[<p>remove_all_images value is &#8216;yes&#8217;</p>
]]></content:encoded>
	</item>
</channel>
</rss>

