Useful Tricks

This section contains some useful programming tricks.
Delete all products

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…

Clear cache/reindex

<?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 Magento Urls in Phtml Page

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();

Return Product Attributes

<?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//…

1 8 9 10 42