Magento : Add custom image attribute to category Just copy paste the below code in header.phtml and run yourmagento once,…
4x Masonry Grid
Magento : Product list page wrong sorting by price When we install webtex_customergroupprice it has a bug when it sorts…
Just you need to replace one line of code in your controllerwhere you want to change the layout of the…
Magento : Change options of configurable product to radio button Replace the configurable.phtml code with below code:<?php$_product = $this->getProduct();$_attributes =…
TRUNCATE TABLE `catalog_product_bundle_option`;TRUNCATE TABLE `catalog_product_bundle_option_value`;TRUNCATE TABLE `catalog_product_bundle_selection`;TRUNCATE TABLE `catalog_product_entity_datetime`;TRUNCATE TABLE `catalog_product_entity_decimal`;TRUNCATE TABLE `catalog_product_entity_gallery`;TRUNCATE TABLE `catalog_product_entity_int`;TRUNCATE TABLE `catalog_product_entity_media_gallery`;TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;TRUNCATE TABLE…
<?php// input is $_product and result is iterating child products$childProducts = Mage::getModel(‘catalog/product_type_configurable’)->getUsedProducts(null, $product);?>
<?php// clear cacheMage::app()->removeCache(‘catalog_rules_dirty’);// reindex pricesMage::getModel(‘index/process’)->load(2)->reindexEverything();/*1 = Product Attributes2 = Product Attributes3 = Catalog URL Rewrites4 = Product Flat Data5 =…
Get Base Url :Mage::getBaseUrl();Get Store Url : Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);Get Skin Url :Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);$this->getSkinUrl(‘images/imagename.jpg’);Get Media Url :Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);Get Js Url : Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);Get Current UrlMage::helper(‘core/url’)->getCurrentUrl();Get Home UrlMage::helper(‘core/url’)->getHomeUrl();
<?php$_product->getThisattribute();$_product->getAttributeText(‘thisattribute’);$_product->getResource()->getAttribute(‘thisattribute’) ->getFrontend()->getValue($_product);$_product->getData(‘thisattribute’);// The following returns the option IDs for an //attribute that is a multiple-select field: $_product->getData(‘color’); // i.e. 456,499//…
Open up the /app/etc/local.xml file, locate the <frontName> tag, and change the ‘admin’ part it to something a lot more…
<?php if($_product->isSaleable()) { // do stuff } ?>
<?phprequire_once(‘app/Mage.php’); //Path to Magentoumask(0);Mage::app();// Run you code here?>
<?phpif($_product->getTypeId() == “configurable”) { $ids = $_product->getTypeInstance()->getUsedProductIds();?><ul> <?php foreach ($ids as $id) { $simpleproduct = Mage::getModel(‘catalog/product’) ->load($id); ?> <li> <?php…
Here, you will see how to create Catalog Price Rule in Magento through code. Catalog Rules are applied on products…
First, use get_class to get the name of an object’s class. <?php $class_name = get_class($object); ?> Then, pass that get_class_methods…
In /app/design/frontend/default/site/template/catalog/product/view/type/ <?php $_helper = $this->helper(‘catalog/output’); ?><?php $_associatedProducts = $this->getAllowProducts() ?><?php //var_dump($_associatedProducts); ?><br /><br /><?php if (count($_associatedProducts)): ?> <?php foreach…
<?php$currentCategory = Mage::registry(‘current_category’);$currentProduct = Mage::registry(‘current_product’);$currentCmsPage = Mage::registry(‘cms_page’);?>
<?php$cart = Mage::getModel(‘checkout/cart’)->getQuote()->getData();print_r($cart);$cart = Mage::helper(‘checkout/cart’)->getCart()->getItemsCount();print_r($cart);$session = Mage::getSingleton(‘checkout/session’);foreach ($session->getQuote()->getAllItems() as $item) { echo $item->getName(); Zend_Debug::dump($item->debug());}?>
Use the code below to delete a quote: <?php$quoteID = Mage::getSingleton(“checkout/session”) ->getQuote()->getId();if($quoteID){ try { $quote = Mage::getModel(“sales/quote”)->load($quoteID); $quote->setIsActive(false); $quote->delete(); return…
UPDATE`core_config_data`SET`value` = 0WHERE`path` = “dev/debug/template_hints”OR`path` = “dev/debug/template_hints_blocks”;
We can simply use the following code // To get the shipping and handling charge on shopping cart page Mage::getSingleton(‘checkout/session’)->getQuote()->getShippingAddress()->getShippingAmount();…
Requirement : Some times you may run into situation where you want to override the core functionality of Magento core…
To create the related product programmatically in Magento <?phpset_time_limit(0);ini_set(‘memory_limit’,’1024M’);require_once ‘../../app/Mage.php’;Mage::app(); $sku=’12345’; //some Sku$product = Mage::getModel(‘catalog/product’)->loadByAttribute(‘sku’,$sku); if($product){$sRelatedProducts = “123456,123”;$aRelatedProducts = explode(‘,’,…
<?php $helper = $this->helper(‘catalog/category’) ?> <?php foreach ($helper->getStoreCategories() as $_category): ?> <a href=”<?php echo Mage::getModel(‘catalog/category’) …