Auto generated SKU when add product in magento

Open /app/design/adminhtml/default/default/template/catalog/product/edit.phtml and add the following code to the bottom of the file:

<?php
$dbread = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’);
$sql = $dbread->query(“SELECT * FROM catalog_product_entity ORDER BY created_at DESC LIMIT 1″);
$res = $sql->fetch();
?>
<script type=”text/javascript”>
if(document.getElementById(‘sku’).value == “”){
document.getElementById(‘sku’).value = <?php echo (int)$res[“sku”] + 1; ?>;
}
</script>

Note:Read the SKU (must be an integer) of the last added product.
Increment the SKU by 1.

0