cancel
Showing results for 
Search instead for 
Did you mean: 

custom script specific store

   Did you know you can see the translated content as per your choice?

Translation is in progress. Please check again after few minutes.

custom script specific store

Hi,

 

I've made a script to set meta title and meta description for a specific storage, with data coming from a csv. They got actually saved, but the odd thing is other fields (seems like random) got the "Use default" flag unset.

 

Why is this?

 

Here is excerpt of my script:

 

if (($handle = fopen($src, "r")) !== FALSE) {
        while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {

            if ($data[0] == 'sku')
                continue;

            $sku = trim($data[0]);
            $**bleep** = trim($data[1]);
            $desc = trim($data[2]);

            if ($sku != '') {
                $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);

                if (!is_object($product) || !$product->getEntityId()) {
                    echo "\nNon trovo il prodotto: $sku\n";
                    continue;
                }

                $product->setStoreId(4)->load($product->getId())->setMetaTitle($**bleep**)->setMetaDescription($desc);

                try {
                    $product->save();
                    $i++;
                } catch (Exception $ex) {
                    die($ex->getMessage());
                }

            }
        }
    }

thanks a lot

1 REPLY 1

Re: custom script specific store

UPDATE:

 

if I replace

 

product->setStoreId(4)->load($product->getId())->setMetaTitle($**bleep**)->setMetaDescription($desc);

 

with

 

$product->setStoreId(4)->setData('meta_title', $**bleep**)->setData('meta_description', $desc);

I really would love to know why is this.

 

Thanks