Auto generated SKU when add product in magento

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

How To Get Special Price in magento Product

How To Get Special Price in magento Product

<?php
Mage::app();
Mage::getSingleton(‘core/session’, array(
‘name’ => ‘frontend’
));
$_productCollection = Mage::getResourceModel(‘catalogsearch/advanced_collection’)-> addAttributeToSelect(Mage::getSingleton(‘catalog/config’)-> getProductAttributes())->addMinimalPrice()->setPageSize(1)->addStoreFilter();
Mage::getSingleton(‘catalog/product_status’)->addVisibleFilterToCollection ($_productCollection);
Mage::getSingleton(‘catalog/product_visibility’)->addVisibleInSearchFilterToCollection ($_productCollection);
$todayDate    = date(‘m/d/y’);
$tomorrow     = mktime(0, 0, 0, date(‘m’), date(‘d’) + 1, date(‘y’));
$tomorrowDate = date(‘m/d/y’, $tomorrow);
$_productCollection->addAttributeToFilter(‘special_from_date’, array(
‘date’ => true,
‘to’ => $todayDate
))->addAttributeToFilter(‘special_to_date’, array(
‘or’ => array(
0 => array(
‘date’ => true,
‘from’ => $tomorrowDate
),
1 => array(
‘is’ => new Zend_Db_Expr(‘null’)
)
)
), ‘left’)->addAttributeToSort(‘special_from_date’, ‘desc’);
?>
<?php
$i = 0;
if ($i++ % 3 == 0)
?>
<ul>
<?php
$x = 2;
?>
<?php
foreach ($_productCollection as $_product) {
if ($_product->getData(‘special_price’) != null) {
?>
<li>
<h2><?php
if ($locale == en_US) {
echo $this->__(‘Special Offers’);
} else if ($locale == el_GR) {
echo $this->__(‘Προσφορές’);
} else {
echo $this->__(‘Special Offers’);
}
?></h2>

<img src=”<?php
echo $this->helper(‘catalog/image’)->init($_product, ‘thumbnail’)->resize(135);
?>” alt=”<?php
echo $_product->getName();
?>” width=”135″ height=”135″ />
<?php
$specialPrice = $_product->getData(‘special_price’);
$orignalPrice = $_product->getData(‘price’);
?>

<?php
}
}
?>

0

Custom Menu In Magento

Custom Menu In Magento

<?php

        $root_category = Mage::getModel(‘catalog/category’)->load(3); // Put your root category ID here.

        $subcategories = $root_category->getChildren();

  foreach(explode(‘,’,$subcategories) as $subcategory) {

        $category = Mage::getModel(‘catalog/category’)->load($subcategory);

        echo ‘<a href=”‘.$category->getURL() .'” />’.$category->getName().'</a><br/>’;

  }

  ?>

0

Add Page In Navigation Menu

Add Page In Navigation Menu

1 Go To CatalogèManage Categories=> Add Sub Categories====note the categories ID

2 Go to CMS èPage => add New Page=====note the the url  key

3 Got To CatalogèURL Rewrite Management=> find Category Id and open store ==note the Request Path and delete this category

4Go toè add url Rewrite => select custom=>ID path– categories ID(1 step path)

Request Path=> Request Path(3 step path)

Target Path =>url Key(2 step path)

0

How to set number of columns in category listing

  1. Go to  app\design\frontend\default\my_theme1\layout\catalog.xml  open file
  2. Paste this   <action  method="setColumnCount"><count>4</count></action> top of the previous layout details
  3. Paste again in bottom side that show previous layout details<action method="setColumnCount"><count>4</count></action>
  4. Save the file
  5. Go To admin Panel and clear all the caches.
0