If you want to export limited fields using custom filter using code and easier way without using admin panel, below is the steps to approach.
Here id, sku, name, price values are getting, if you want more then you can append below in the field.
<?php require_once 'app/Mage.php'; ini_set('display_errors', 1); umask(0); Mage::app('default'); set_time_limit(0); ini_set('memory_limit','1024M'); function empty_pk($data){ if($data!=''){return $data;} else {return " ";} } //Instantiate product collection $collection = Mage::getModel('catalog/product')->getCollection(); //filter for name is 'ABC' $collection->addAttributeToFilter('name','ABC'); //filter for status = 1 enabled $collection->addAttributeToFilter('status', array('eq' => 1)); //1 - enabled, 2 - disabled //Below filter is getting range of entity_id between 100 and 2000 //filter for entity id is greater than (gt) 100 $collection->addFieldToFilter(array( array('attribute'=>'entity_id','gt'=>'100') )); //AND filter for entity id is less than (lt) 2000 $collection->addFieldToFilter(array( array('attribute'=>'entity_id','lt'=>'2000') )); //A full list of the supported short conditionals (eq,lt, etc.) can be found in the _getConditionSql method in lib/Varien/Data/Collection/Db.php echo '<table border="1"> '; echo '<tr>'; echo "<th>id</th>"; echo "<th>sku</th>"; echo "<th>name</th>"; echo "<th>price</th>"; ... //add here more field echo '</tr>'; foreach ($collection as $product_all) { $sku = $product_all['sku']; // retrieve product id using sku $product_id = Mage::getModel('catalog/product')->getIdBySku($sku); // call product model and create product object $product = Mage::getModel('catalog/product'); // Load product using product id $product->load($product_id); $pk_entity = empty_pk($product['entity_id']); $pk_sku = empty_pk($product['sku']); $pk_name = empty_pk($product['name']); $pk_price = empty_pk($product['price']); echo '<tr>'; echo "<td>".$pk_entity."</td>"; echo "<td>".$pk_sku."</td>"; echo "<td>".$pk_name."</td>"; echo "<td>".$pk_price."</td>"; ... //print here more field echo '</tr>'; } echo '</table>'; ?>
Hurray..!! this retrieve desired values from the database easier way out.
©2021. All rights reserved. Terms of Use | Privacy Policy
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
Recent Comments