Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <?php
  2.  
  3. require_once('../app/Mage.php');
  4. Mage::app();
  5.  
  6. ######################### THIS IS THE FILE THAT HOLDS THE SIMPLE SKU'S #########################################
  7. $file = '../var/export/sku-list.csv';
  8.  
  9. ######################### THIS IS THE FILE YOU WILL EXPORT CONFIGURABLE DESCRIPTIONS TO #######################
  10. $file2 = fopen('../var/export/jare2.csv', 'w');
  11.  
  12.  
  13. $csv = file($file, FILE_IGNORE_NEW_LINES);
  14.  
  15. $products = Mage::getResourceModel('catalog/product_collection')
  16. ->setStoreId(1)
  17. ->addAttributeToSelect('sku')
  18. ->addAttributeToFilter('sku', array('in' => $csv));
  19.  
  20. foreach ($products as $product) {
  21.  
  22. $childId = $product->getId();
  23. $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($childId);
  24.  
  25. $parents = Mage::getResourceModel('catalog/product_collection')
  26. ->setStoreId(1)
  27. ->addFieldToFilter('entity_id', array('in'=>$parentIds))
  28. ->addAttributeToSelect('sku')
  29. ->addAttributeToSelect('short_description');
  30.  
  31. foreach ($parents as $parent) {
  32. $sku = $parent->getSku();
  33.  
  34. if($description = $parent->getShortDescription()) {
  35. $description = $parent->getShortDescription();
  36. } else {
  37. $description = "";
  38. }
  39.  
  40. $description = str_replace( "\r", "", $description); // Removes the irritating ^M sign that occurs when it's a Windows document
  41. $description = str_replace( "\n", "", $description); // Removes newlines
  42.  
  43. fputcsv($file2, array(
  44. $sku,
  45. strip_tags($description)
  46. ), ',');
  47. }
  48.  
  49. }
  50.  
  51.  
  52. fclose($file);
  53. fclose($file2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement