1

I'm trying to import a category array with AvS/FastSimpleImport where:

Index 0: the default scope Index 1: values for the it store Index 2: values for the en store

The goal is to set Use default value for the ###EMPTY### values.

This is my array, and it works like a charm:

‌‌$arrAvS
‌array (
  0 => 
  array (
    '_root' => 'Default Category',
    'is_active' => 'yes',
    'include_in_menu' => 'yes',
    'available_sort_by' => NULL,
    'default_sort_by' => 'position',
    'display_mode' => 'static block only',
    'code_category' => 'D',
    '_category' => 'My category',
    'url_key' => 'my-cat',
    'meta_title' => 'DEFAULT: meta-title',
    'meta_description' => 'DEFAULT: meta-descr',
    'description' => 'DEFAULT: descr',
  ),
  1 => 
  array (
    '_store' => 'it',
    'name' => 'IT: name',
    'url_key' => 'it-slug',
    'meta_title' => 'ITA: meta-title',
    'meta_description' => 'ITA: meta-descr',
    'description' => 'ITA: descr',
  ),
  2 => 
  array (
    '_store' => 'en',
    'meta_title' => 'EN: meta-title',
    'meta_description' => 'EN: meta-descr',
    'name' => 'EN: name',
    'url_key' => 'en-slug',
    'description' => 'EN: description',
  ),
)

Again, this works as expected.

The problem occurs when I want to set the store value to Use default value. For example, i change the second array from 'name' => 'EN: name', to 'name' => '###EMPTY###' (description also). In this scenario, the name|description fields in the EN storeview simply get set to empty

Screenshot

The importing code is:

$import = Mage::getModel('fastsimpleimport/import');
$import->processCategoryImport($arrAvS);

Admin config:

Screenshot

The store is a july-SUPEE patched Magento ver. 1.9.2.4.

AvS is 0.7.1.

Any help is greatly appreciated


One more example:

````

    $data = array();
    $data[] = array(
        '_root' => 'Default Category',
        '_category' => 'Myyy Category',
        'description' => 'Myyy Category Description',
        'is_active' => 'yes',
        'include_in_menu' => 'yes',
        'meta_description' => 'Myyy Category Meta',
        'available_sort_by' => 'position',
        'default_sort_by' => 'position',
    );

    $data[] = array(
        '_store' => 'en',
        'name' => 'I don't want to put a custom text here, must use default',
        'description' => 'Myyy Category EN DESCR'
    );


    $this->import
        ->processCategoryImport($data);

````

To use default for name, I changed the second element to:

'name' => false

nope, still do not use default, displays empty text

'name' => null,

nope

'name' => Mage::getStoreConfig('fastsimpleimport/general/symbol_for_clear_field')

nope

I'm fresh out of ideas, thanks

0

"Use default value" function is base on product attribute value is bool false. like below:

$product->setName(false)

Good luck!

Additional:

For category import, extension do no deal with ###EMPTY### such case, and it also does not implement standard model method. You can rewrite the function AvS_FastSimpleImport_Model_Import_Entity_Category->_saveCategoryAttributes like below

   protected function _saveCategoryAttributes(array $attributesData)
{
    foreach ($attributesData as $tableName => $data) {
        $tableData = array();
        foreach ($data as $entityId => $attributes) {

            foreach ($attributes as $attributeId => $storeValues) {
                foreach ($storeValues as $storeId => $storeValue) {
                    if (!is_null($storeValue)) {
                        $tableData[] = array(
                            'entity_id' => $entityId,
                            'entity_type_id' => $this->_entityTypeId,
                            'attribute_id' => $attributeId,
                            'store_id' => $storeId,
                            'value' => $storeValue
                        );
                    } else {
                        // change start
                        $this->_connection->delete($tableName,array(
                            'entity_id' => $entityId,
                            'entity_type_id' => $this->_entityTypeId,
                            'attribute_id' => $attributeId,
                            'store_id' => $storeId,
                        )
                        // change end
                        );
                }

                }
            }
        }
        $this->_connection->insertOnDuplicate($tableName, $tableData, array('value'));
    }
    return $this;
}

That will make ###EMPTY### work to use default value for category import.

  • As you can read, I'm using an array and not an object. I tried 'name' => false but didn't work. – Dr. Gianluigi Zane Zanettini Aug 25 '17 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.