Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Import Issue - Import Sets Certain Fields’ Values to Default or Removes Them Completely
 
tkepler
Jr. Member
 
Total Posts:  4
Joined:  2013-05-22
 

Hi,

I am having an issue with the magento Import.  When doing a simple price update using the System->Import/Export->Import and selecting Products and Append Complex Data, certain fields that are not present in my .csv feed get set to their default value or cleared completely if the attribute has no default value.

For example, if my feed contains the sku and price of a product (the product is already created, I just want to update the price), but does not contain the visibility of a product, the product’s value for visibility is being removed.

So far, I have identified these attributes where this is occuring:

Visibility (Has no default value, gets cleared completely)
Free Shipping (Gets set to the default value of “No")
Multiply Attributes (Gets set to the default value of “No")

Other attributes such as Availability, Material, Manufacturer, etc. are not being affected at all.

Does anyone have any ideas as to why this is happening and possible solutions?

Thanks,

PS - We are using Magento ver. 1.7.0.2

 
Magento Community Magento Community
Magento Community
Magento Community
 
tkepler
Jr. Member
 
Total Posts:  4
Joined:  2013-05-22
 

Has no one else had this issue?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Store_Manager
Enthusiast
 
Avatar
Total Posts:  867
Joined:  2012-07-09
 

Hello,

If you use default Magento import method and you think that you may include in the file only SKU and price and update your data, then you are mistaken. Magento has a range of obligatory fields to be included in the file (even if you do not need them).  Here is the article on the fields Magento “insists on” -
http://www.mag-manager.com/useful-articles/tipstricks/required-csv-file-values-for-error-free-magento-import-via-admin

If you do not want to adjust your file including all those fields, you can try import via Store Manager for Magento. With this tool, having only 2 fields - SKU and price you will be able to update price of your goods and other product details will remain unchanged (won’t be overwritten).
If you are interested, you may try it out, since there is 2-weeks free fully-functional version -
http://www.magentocommerce.com/magento-connect/store-manager-for-magento.html
The solution is desktop one, so installation requires only a few clicks “Next”. Let me know if you need any assistance.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Barbariz
Jr. Member
 
Total Posts:  2
Joined:  2008-10-14
 

I found the solution in this link.
http://blog.gilesbennett.com/magento-bug-product-import-resets-attribute-values/

It delete (or comment) the function that replace empty values to default.

====
A little digging revealed the source of the problem. In

app/code/core/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php
there’s a function called prepareAttributesForSave. Within this function (lines 303 – 304) there’s an elseif clause which looks like this :

elseif (null !== $attrParams['default_value']{
$resultAttrs[$attrCode] 
$attrParams['default_value'];
}

What that’s doing is setting the attribute to its default value if it’s not contained in the CSV being processed. So resetting everything – great.

To undo it, simply make a local copy at

app/code/local/Mage/ImportExport/Model/Import/Entity/Product/Type/Abstract.php
and remove the elseif clause in question, so the remainder of that function looks like this :

public function prepareAttributesForSave(array $rowData)
    
{
        $resultAttrs 
= array();

        foreach (
$this->_getProductAttributes($rowData) as $attrCode => $attrParams{
            
if (!$attrParams['is_static']{
                
if (isset($rowData[$attrCode]) && strlen($rowData[$attrCode])) {
                    $resultAttrs[$attrCode] 
=
                        (
'select' == $attrParams['type'|| 'multiselect' == $attrParams['type'])
                        ? 
$attrParams['options'][strtolower($rowData[$attrCode])]
                        
$rowData[$attrCode];
                
elseif (array_key_exists($attrCode$rowData)) {
                    $resultAttrs[$attrCode] 
$rowData[$attrCode];
                
}
            }
        }
        
return $resultAttrs;
    
}

And that’s it – if your imported CSV doesn’t mention a particular attribute, it won’t be changed back to the default.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top