Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('../app/Mage.php');
- Mage::app();
- ######################### THIS IS THE FILE THAT HOLDS THE SIMPLE SKU'S #########################################
- $file = '../var/export/sku-list.csv';
- ######################### THIS IS THE FILE YOU WILL EXPORT CONFIGURABLE DESCRIPTIONS TO #######################
- $file2 = fopen('../var/export/jare2.csv', 'w');
- $csv = file($file, FILE_IGNORE_NEW_LINES);
- $products = Mage::getResourceModel('catalog/product_collection')
- ->setStoreId(1)
- ->addAttributeToSelect('sku')
- ->addAttributeToFilter('sku', array('in' => $csv));
- foreach ($products as $product) {
- $childId = $product->getId();
- $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($childId);
- $parents = Mage::getResourceModel('catalog/product_collection')
- ->setStoreId(1)
- ->addFieldToFilter('entity_id', array('in'=>$parentIds))
- ->addAttributeToSelect('sku')
- ->addAttributeToSelect('short_description');
- foreach ($parents as $parent) {
- $sku = $parent->getSku();
- if($description = $parent->getShortDescription()) {
- $description = $parent->getShortDescription();
- } else {
- $description = "";
- }
- $description = str_replace( "\r", "", $description); // Removes the irritating ^M sign that occurs when it's a Windows document
- $description = str_replace( "\n", "", $description); // Removes newlines
- fputcsv($file2, array(
- $sku,
- strip_tags($description)
- ), ',');
- }
- }
- fclose($file);
- fclose($file2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement