Question

I have products that need to be imported into different stores

sku, name, store1, store2, subcat

111, item1, coke, pepsi, subcategory

i wrote out some logic that works for the value replacer plugin:

[{item.store1}]/{item.subcat};;[{item.store2}]/{item.subcat}

the problem is, what if i have some items that only have a value under store1 and are blank for store2 or the opposite?

I get an error when importing that says Cannot find site root with names : ,

Does anyone know of there is a way to work around this?

Was it helpful?

Solution

You can use a PHP ternary operator written in the Magmi value replacer advanced syntax to append the value if the store2 column value exists.

[{item.store1}]/{item.subcat}{{(!empty({item.store2}) ? ';;['.{item.store2}.']/'.{item.subcat} : '')}}

This basically says if item.store2 is not empty, then return ;;[{item.store2}]/{item.subcat}

In actual PHP, this would look more like

(!empty($item['store2']) ? ';;['.$item['store2'].']/'.$item['subcat'] : '');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top