Tag Archives: PHP

List sub-categories on a category page flat catalog enabled Magento

<?php
$_cat = new Mage_Catalog_Block_Navigation();
$currentCat = $_cat->getCurrentCategory();
$subCats = Mage::getModel(‘catalog/category’)->load($currentCat->getId())->getChildren();
$subCatIds = explode(‘,’,$subCats);
?>

<?php if (count($subCatIds) > 1): ?>
<ul>
<?php foreach($subCatIds as $subCatId): ?>
<?php $subCat = Mage::getModel(‘catalog/category’)->load($subCatId); ?>

<li>
<a href=”<?php echo $subCat->getUrl(); ?>”>
<?php echo $subCat->getName(); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

List sub-categories on a category page Magento

<?php
$_cat = new Mage_Catalog_Block_Navigation();
$currentCat = $_cat->getCurrentCategory();
$subCats = Mage::getModel(‘catalog/category’)->load($currentCat->getId())->getChildren();
$subCatIds = explode(‘,’,$subCats);
?>

<?php if (count($subCatIds) > 1): ?>
<ul>
<?php foreach($subCatIds as $subCatId): ?>
<?php $subCat = Mage::getModel(‘catalog/category’)->load($subCatId); ?>

<li>
<a href=”<?php echo $subCat->getUrl(); ?>”>
<?php echo $subCat->getName(); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

Standard paypal payment gateway integration PHP

<?php
$business = “premmelethu@gmail.com”; // Email associated with paypal
$amount = “100.00”; // Amount to be paid
$paypalUrl = “https://www.sandbox.paypal.com/cgi-bin/webscr” ;// Choose this url for testing and make sure that you have changed this when set to live
$return = “http://phpcodez.com/payment-successful.php” ;// Make sure that you have created this page
$cancel = “http://phpcodez.com/payment-cancel.php”;// Make sure that you have created this page
?>
<form class=”paypal” action=”<?php echo $paypalUrl; ?>” method=”post” id=”paypal_form” >
<input type=”hidden” name=”lc” value=”US” />
<input type=”hidden” name=”currency_code” value=”USD” />
<input type=”hidden” name=”first_name” value=”PHPCodez” />
<input type=”hidden” name=”item_number” value=”123456″ / >
<input type=”hidden” name=”return” value=”<?php echo $return; ?>” / >
<input type=”hidden” name=”cancel_return” value=”<?php echo $cancel; ?>” / >
<input type=”hidden” name=”business” value=”<?php echo $business; ?>” / >
<input type=”hidden” name=”item_name” value=”PHPCodez Book” / >
<input type=”hidden” name=”amount” value=”<?php echo $amount; ?>” / >
<input type=”submit” value=”Pay 100 $”/>
<input type=”hidden” name=”cmd” value=”_xclick” />
</form>