daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Dec 13th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ini_set('display_errors', 'On');
  2. error_reporting(E_ALL);
  3.  
  4. require('../app/Mage.php');
  5. Mage::app();
  6.  
  7. $product = Mage::getModel('catalog/product')->load(409728);
  8. Mage::register('current_product', $product);
  9. $seotitle = Mage::helper('seo')->getCurrentSeo();
  10. $productnamestring = Mage::getSingleton('seo/object_product')->getTitle();
  11.  
  12.         $findseo = array('/h+inch (?:(i[357])-w+|h+w+)?/', '/(w+)#w+/', '/(^| )(.{4,}) (.*)2/', '/s*-s*$/');
  13.         $replaceseo = array('" $1', '$1', '$1$2 $3', '');
  14.         $productnamingseo = preg_replace($findseo, $replaceseo, $productnamestring);
  15.  
  16. $product->setName($productnamingseo);
  17. $product->getResource()->saveAttribute($product, 'name');
  18.    
  19. ini_set('display_errors', 'On');
  20. error_reporting(E_ALL);
  21.  
  22. require('../app/Mage.php');
  23. Mage::app();
  24.  
  25.  
  26. $file_path = "../var/import/productname.csv";
  27. $mage_csv = new Varien_File_Csv();
  28. $products_row = array();
  29.  
  30. $products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
  31.  
  32. foreach ($products as $product) {
  33.     $prod = Mage::register('current_product', $product);    
  34.     $seotitle = Mage::helper('seo')->getCurrentSeo();
  35.     $productnamestring = Mage::getSingleton('seo/object_product')->getTitle();
  36.  
  37.     $findseo = array('/h+inch (?:(i[357])-w+|h+w+)?/', '/(w+)#w+/', '/(^| )(.{4,}) (.*)2/', '/s*-s*$/');
  38.     $replaceseo = array('" $1', '$1', '$1$2 $3', '');
  39.     $productnamingseo = preg_replace($findseo, $replaceseo, $productnamestring);
  40.  
  41.     $data = array();
  42.     $data['sku'] = $product->getSku();
  43.     $data['name'] = $productnamingseo;
  44.     $products_row[] = $data;
  45. }
  46.  
  47. $mage_csv->saveData($file_path, $products_row);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top