0

I want to export enabled simple products SKU from magento admin export function is not working fine. I have tried to export many times, and it's showing too many extra records. Now i want to try exporting from a MySQL query. I will need the results in the form of a CSV file.

Get Parent Config and Child Associated SKU's List.

0

Put this file in your magento root folder.

<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
<?php 
require_once 'app/Mage.php';
Mage::app()->setCurrentStore(0);
set_time_limit(0);
$products=Mage::getModel('catalog/product')->getCollection()
      ->addAttributeToSelect('sku')
      ->addFieldToFilter('status',array(1));
$count =0;
$attr_array=array();
?>
<table border="2" id="myTable">
<tr>
<td>SKU</td>
</tr>
<?php
    foreach($products as $pro){
   ?>
   <tr><td><?php echo $pro['sku'] ?></td></tr>
   <?php
   }
?>
</table>
 <a href="#" id="test" onClick="javascript:fnExcelReport();">download</a>
 <script>
function fnExcelReport() {
var tab_text = '<html xmlns:x="urn:schemas-microsoft-com:office:excel">';
tab_text = tab_text + '<head><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet>';

tab_text = tab_text + '<x:Name>Test Sheet</x:Name>';

tab_text = tab_text + '<x:WorksheetOptions><x:Panes></x:Panes></x:WorksheetOptions></x:ExcelWorksheet>';
tab_text = tab_text + '</x:ExcelWorksheets></x:ExcelWorkbook></xml></head><body>';

tab_text = tab_text + "<table border='1px'>";
tab_text = tab_text + $('#myTable').html();
tab_text = tab_text + '</table></body></html>';

var data_type = 'data:application/vnd.ms-excel';

var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");

if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) {
    if (window.navigator.msSaveBlob) {
        var blob = new Blob([tab_text], {
            type: "application/csv;charset=utf-8;"
        });
        navigator.msSaveBlob(blob, 'all_skus.xls');
    }
} else {
    $('#test').attr('href', data_type + ', ' + encodeURIComponent(tab_text));
    $('#test').attr('download', 'all_skus.xls');
}
}
</script>

And then run the file,for example

yourdomain.com/file_name.php

And click the download below the result,you will get result in csv file.

  • let me know,if this is your solution. – Nagaraj Juro Jan 11 '18 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.