PHP, Magento, Codigniter, Opencart and Wordpress Developer. Contact for school and college projects on PHP, Codiegniter, Wordpress, Mysql etc.
Showing posts with label Magento. Show all posts
Showing posts with label Magento. Show all posts
Thursday, 20 October 2016
How to call static block in CMS page in admin?
Call static block in CMS Page by following code:
{{block type="cms/block" block_id="your_block_id"}}
Tuesday, 5 April 2016
How to display “You Save” option on product detail page in Magento
You want to display "You Save: $ 0000" Price for "Special Price" on product detail page in Magento. Then you can follow the following steps:
Copy following file:
app/design/frontend/base/default/template/catalog/product/price.phtml
to your theme folder:
app/design/frontend/default/yourtemplate/template/catalog/product/price.phtml
Then
Paste Following code, After
<?php else: /* if ($_finalPrice == $_price): */ ?>
Paste Code:
<?php if( $cb_finalPrice < $cb_OrgPrice ) : ?>
<?php
$_saveDiscountPercent = 100 - round(($cb_finalPrice / $cb_OrgPrice) * 100); // if you want to display save percentage
$_saveDiscountAmount = number_format(($cb_OrgPrice - $cb_finalPrice), 2);
?>
<p class="cbsave">
<span class="price-label label">You Save : </span>
<span class="price">
<strong class="save-discont-amount">
$<?php echo $_saveDiscountAmount ; ?>
<?php echo '('.$_saveDiscountPercent .'%)';
// if you want to display save percentage ?>
</strong>
</span>
</p>
<?php endif; ?>
Saturday, 30 January 2016
How to display category name by product id in Magento
If you want to get Category Name by Product Id in Magento. Use following code:
<?php
$product = Mage::getModel('catalog/product')->load($_product->getId());
$cat_id = $product->getCategoryIds();
foreach($cat_id as $categorycbId) {
$category_id = Mage::getModel('catalog/category')->load($categorycbId);
echo $category_id->getName();
}
?>
Friday, 29 January 2016
How to display static block with title in phtml file : Magento
If you want to display static block in PHTML file in Magento. We can use following code:
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('identifier')->toHtml() ?>
But If you want to display static block with title. So, we can you following code:
<?php
$block = Mage::getModel('cms/block')--->load('identifier');
echo $block->getTitle();
echo $block->getContent();
?>
Tuesday, 22 December 2015
How to get category name by product id in magento?
You can get category name by product id by following code. Where You want display category name, put the code.
<?php $product = Mage::getModel('catalog/product')->load($_product->getId());
$cats = $product->getCategoryIds();
foreach($cats as $categoryId) {
$category = Mage::getModel('catalog/category')->load($categoryId);
echo $category->getName();
}
?>
Monday, 14 December 2015
Magento: Fatal error call to undefined function curl_setopt() in curl.php
If your magento page display this error so please check CURL is enable or not in php.ini file.
If not then enable curl in php.ini file.
Please find "extension=php_curl.dll" in php.ini file. And remove ";" from starting. Like below:
;extension=php_curl.dll
to
extension=php_curl.dll
How to clean logs through database in Magento?
If you want to delete Magento logs through database. So truncate the some table which have logs data. So execute following sql query in database:
SET foreign_key_checks = 0;
TRUNCATE dataflow_batch_export;
TRUNCATE dataflow_batch_import;
TRUNCATE log_customer;
TRUNCATE log_quote;
TRUNCATE log_summary;
TRUNCATE log_summary_type;
TRUNCATE log_url;
TRUNCATE log_url_info;
TRUNCATE log_visitor;
TRUNCATE log_visitor_info;
TRUNCATE log_visitor_online;
TRUNCATE report_viewed_product_index;
TRUNCATE report_compared_product_index;
TRUNCATE report_event;
TRUNCATE index_event;
TRUNCATE catalog_compare_item;
SET foreign_key_checks = 1;
Friday, 11 December 2015
What is difference between shopping cart price rules and catalog price rules Magento?
Magento : Difference between shopping cart price rules and catalog price rules
Shopping Cart Price Rules
Shopping cart price rules can be use for Attribute wise discount, product discount/sale discount, Customer group wise discount, Country wise discount under the certain conditions. Shopping cart price rules use coupon code but not necessary, you can create rule without coupon code also. Shopping cart price rules always apply on shopping cart when conditions are meet. Discount appears on the shopping cart page under the subtotal.
Catalog Price Rules
Catalog price rules use for products discounts or products sales discount under certain conditions. Catalog price rules do not use coupon codes, because they are applied before the product add to cart. Discount appears on products listing.
Thursday, 10 December 2015
How to get subcategories of current category in magento?
Display all the subcategories of any category in Magento.
If you have a category ID (current category OR any category) then you can easily display all the subcategories of that particular category.
Below code will load all the subcategories of the current category.
If you want to get all the subcategories of any specific category, so assign category id in $categoryID.
<?php
$catID = $current_category->getId(); //or any specific category id, e.g. 5
$children = Mage::getModel('catalog/category')->getCategories($catID);
foreach ($children as $category)
{
echo $category->getId();
echo $category->getName();
echo $category->getRequestPath();
print_r($category->getData());
}
?>
How to get sub categories by parent category id in Magento?
You can try below code for display all sub category of one particular category by category id.
<?php
$category_id = 13; // you can change category id according to you
$parentCat = Mage::getModel('catalog/category')->load($category_id);
$subCat = explode(',',$parentCat ->getChildren());
$collection = $parentCat
->getCollection()
->addAttributeToSelect("*")
->addFieldToFilter("entity_id", array("in", $subCat) );
foreach($collection as $catname)
{
echo $catname->getName();
}
?>
How to get custom option values in Magento?
If you want custom options value in magento. Then
You can try following code.
<?php
$customoptions = $item->getProductOptions();
foreach($customoptions ['options'] as $key=>$valuecb)
{
echo $valuecb['label'];
echo $valuecb['option_value'];
}
}
?>
Tuesday, 31 March 2015
Magento - Display Full Breadcrumb Path on product page
Copy core file to local:
app\code\local\Mage\Catalog\Block\Breadcrumbs.php
Change "protected function _prepareLayout()" function from following code:
/** * Preparing layout * * @return Mage_Catalog_Block_Breadcrumbs */
protected function _prepareLayout()
{
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) { $breadcrumbsBlock->addCrumb('home', array( 'label'=>Mage::helper('catalog')->__('Home'),
'title'=>Mage::helper('catalog')->__('Go to Home Page'),
'link'=>Mage::getBaseUrl()
));
// sometimes magento can't get category associated with a product
// so the full breadcrumb is not shown // this is a hack to fix the issue.
$current_category = Mage::registry('current_category');
$current_product = Mage::registry('current_product');
// let's check if magento knows what current category is
// if it doesn't know, let's feed this info to it's brain :)
if(!$current_category && $current_product){
$categories = $current_product->getCategoryCollection()->addAttributeToSelect('name')->setPageSize(1);
foreach($categories as $category) { Mage::unregister('current_category');
Mage::register('current_category', $category);
}
}
$title = array(); $path = Mage::helper('catalog')->getBreadcrumbPath();
foreach ($path as $name => $breadcrumb) { $breadcrumbsBlock->addCrumb($name, $breadcrumb);
$title[] = $breadcrumb['label'];
}
if ($headBlock = $this->getLayout()->getBlock('head')) { $headBlock->setTitle(join($this->getTitleSeparator(), array_reverse($title))); }
}
return parent::_prepareLayout();
}
Monday, 30 March 2015
How to delete all orders from Magento?
Go to Phpmyadmin and run following sql code:
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
TRUNCATE `sales_flat_creditmemo_grid`;
TRUNCATE `sales_flat_creditmemo_item`;
TRUNCATE `sales_flat_invoice`;
TRUNCATE `sales_flat_invoice_comment`;
TRUNCATE `sales_flat_invoice_grid`;
TRUNCATE `sales_flat_invoice_item`;
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_payment`;
TRUNCATE `sales_flat_order_status_history`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_quote_payment`;
TRUNCATE `sales_flat_quote_shipping_rate`;
TRUNCATE `sales_flat_shipment`;
TRUNCATE `sales_flat_shipment_comment`;
TRUNCATE `sales_flat_shipment_grid`;
TRUNCATE `sales_flat_shipment_item`;
TRUNCATE `sales_flat_shipment_track`;
TRUNCATE `sales_invoiced_aggregated`;
TRUNCATE `sales_invoiced_aggregated_order`;
TRUNCATE `sales_order_aggregated_created`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_flat_creditmemo` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_creditmemo_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_invoice_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_status_history` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_payment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_shipping_rate` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_comment` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_grid` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_shipment_track` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated` AUTO_INCREMENT=1;
ALTER TABLE `sales_invoiced_aggregated_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_aggregated_created` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;
Subscribe to:
Posts (Atom)