- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2016
05:40 AM
11-22-2016
05:40 AM
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
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2016
03:52 AM
11-23-2016
03:52 AM
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