Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* file to get sku, pixel_height, pixel_width under 4000 */
- // make sure we don't time out
- set_time_limit(0);
- // include Mage
- require_once 'app/Mage.php';
- Mage::app('default');
- $pixel_height = 4000;
- $pixel_width = 4000;
- $dt = time();
- //$filename = $dt."_pix_size_export.csv";
- $filename = "pix_size_export.csv";
- $headers = array('sku', 'pixel_height', 'pixel_width');
- // open file for writing
- $fp = fopen($filename, 'w');
- fputcsv($fp, $headers); // add headers to file
- echo "<p>Getting products with pix_height <= ".$pixel_height." and pix_width <= ".$pixel_width."</p>";
- $products = Mage::getModel('catalog/product')
- ->getCollection()
- ->addAttributeToFilter('status', 1) //enabled
- ->addAttributeToFilter(array(
- array(
- 'attribute' => 'pixel_height',
- 'gteq' => $pixel_height
- ),
- array(
- 'attribute' => 'pixel_width',
- 'gteq' => $pixel_width
- )
- ))
- //->addAttributeToFilter('pixel_height', array('gteq' => $pixel_height))
- //->addAttributeToFilter('pixel_width', array('gteq' => $pixel_width))
- ->addAttributeToSelect('sku')
- ->addAttributeToSelect('pixel_height')
- ->addAttributeToSelect('pixel_width');
- //echo $products->getSelect();
- //exit;
- echo "<p>Total Products Found: ".$products->count()."</p>";
- echo "<pre>";
- foreach($products as $p) {
- $data = array(
- 'sku' => $p->getSku(),
- 'pixel_height' => $p->getPixelHeight(),
- 'pixel_width' => $p->getPixelWidth()
- );
- //print_r($data);
- fputcsv($fp, $data);
- }
- echo "</pre>";
- echo "<p>File created: <a href='".$filename."'>".$filename."</a></p>";
- fclose($fp);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement