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

Setting default vaules on product import [Partially Solved]
 
invaderflid
Member
 
Avatar
Total Posts:  59
Joined:  2008-10-21
Northport Long Island New York
 

Hello everyone,

I’ve successfully modified the product import so that I don’t need the sku, type, websites, attribute_set, store, and category_ids to be set in my CSV file for importing. I’m having a little more trouble figuring out how to accomplish this with the status, visibility and is_in_stock.

A quick example of how I got this to work:

if (empty($importData['store'])) {
            
if (!is_null($this->getBatchParams('store'))) {
                $store 
$this->getStoreById($this->getBatchParams('store'));
            
else {
               
/*Mod: Remove errors and set default value
                $message = Mage::helper('catalog')->__('Skip import row, required field "%s" not defined', 'store');
                Mage::throwException($message);*/
                
$importData['store''admin'//my code
            
}
        } 
else {
            $store 
$this->getStoreByCode($importData['store']);
        
}

        
if ($store === false{
               
/*Mod: Remove errors and set default value
                $message = Mage::helper('catalog')->__('Skip import row, store "%s" field not exists', $importData['store']);
            Mage::throwException($message);*/
                
$importData['store''admin'//my code
        
}

This code is located in ROOT_FOLDER/app/code/core/Mage/catalog/Model/Convert/Adapter/Product.php.

Hope this helps someone and thanks in advance for any advice, tips etc.

 
Magento Community Magento Community
Magento Community
Magento Community
 
MageParts
Guru
 
Avatar
Total Posts:  415
Joined:  2007-11-18
 

Hi!
I’m currently working on a similar solution, though I’m gunning for it in a different approach. Seeing as nearly all of these attributes can be set to keep a default value the preferred way would be to let your clients set that value in Catalog -> Manage Attributes -> Manage Attrbiutes. Although, some of the attributes, for example website_id, are not visible in that section. So there are a few kinks to be worked out, but I’ll post back as soon as I’ve figured this out smile.

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