Magento category product count

Magento
Many times we need to show product count per category in magento. So here I am showing to how many products (Product count) in that categories. First of all I get all categories based on category position with ascending order and then get product count for that category. It shows like below example: Laptops (4) Hard Drives (4) Root Catalog (5) Monitors (4) Shirts (19) Shoes (46) Get category and product count in magento [php] <?php $categories = Mage::getModel('catalog/category')->getCollection() ->addAttributeToSelect('name') ->addAttributeToSelect('url_key') ->addAttributeToSelect('my_attribute') ->addAttributeToSelect('position') ->addAttributeToSort('position', 'ASC') ->setLoadProductCount(true) ->addAttributeToFilter('is_active',array('eq'=>true)) ->load(); ?> <?php foreach($categories as $key=>$category): ?> <?php if($category->getName() != ''):?> <?php $prodCollection = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($category); // Magento product collection ?> <a href="<?php echo $category->getUrl() ?>"><?php echo $category->getName() ?></a> (<?php echo $prodCollection->count() ?>)<br/> <?php endif;?> <?php endforeach; ?> [/php] [JWD-Magento-Development]
Read More

Remove all products,categories,customers,orders from magento

Magento
If you want to delete all products, categories, customers and orders or sample data from magento database using phpmyadmin then this is very help to you. Here I show you how you can delete all products from magento database as well as all categories,customers and orders. Delete all products from magento database Below code to delete all product and their related records from magento database. [sourcecode language="plain"] 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 `catalog_product_entity_text`; TRUNCATE TABLE `catalog_product_entity_tier_price`; TRUNCATE TABLE `catalog_product_entity_varchar`; TRUNCATE TABLE `catalog_product_link`; TRUNCATE TABLE `catalog_product_link_attribute`; TRUNCATE TABLE `catalog_product_link_attribute_decimal`; TRUNCATE TABLE `catalog_product_link_attribute_int`; TRUNCATE TABLE `catalog_product_link_attribute_varchar`; TRUNCATE TABLE `catalog_product_link_type`; TRUNCATE TABLE `catalog_product_option`; TRUNCATE TABLE `catalog_product_option_price`; TRUNCATE TABLE `catalog_product_option_title`;…
Read More

How to add SSL certificate magento

Magento
Here I can show how to install SSL certificate in Magento. Before we go to Magento SSL certificate this important to know all what is SSL and why we need this. What is SSL? SSL is an acronym for Secure Sockets Layer, an encryption technology that was created by Netscape. SSL creates an encrypted connection between your web server and your visitors' web browser allowing for private information to be transmitted without the problems of eavesdropping, data tampering, or message forgery. Once you have done the SSL install, you can access a site securely by changing the URL from http:// to https://. When an SSL certificate is installed on a website, you can be sure that the information you enter (credit card or any other information), is secured and only…
Read More

Override Magento Admin Controller

Magento
When you use magento sometime need to customize some admin core functionality based on requirement. If you want to change core functionality of any controller so you need to override controller action with your controller action. Learning how to perform this action may be helpful to those who have computer forensics degrees. how to override magento admin controller action This example to show you override edit action from ProductController.php is located app/code/core/Mage/Adminhtml/controllers/Catalog Step 1: Create new module from app/etc/Justwebdevelopment_Overridecontroller.xml [sourcecode language="plain"] <?xml version="1.0"?> <config> <modules> <Justwebdevelopment_Overridecontroller> <active>true</active> <codePool>local</codePool> </Justwebdevelopment_Overridecontroller> </modules> </config> [/sourcecode] Step 2: Make config.xml from app/code/local/Justwebdevelopment/Overridecontroller/etc/config.xml [sourcecode language="plain"] <?xml version="1.0"?> <config> <modules> <Justwebdevelopment_Overridecontroller> <version>0.0.1</version> </Justwebdevelopment_Overridecontroller> </modules> <admin> <routers> <adminhtml> <args> <modules> <Justwebdevelopment_Overridecontroller before="Mage_Adminhtml">Justwebdevelopment_Overridecontroller</Justwebdevelopment_Overridecontroller> </modules> </args> </adminhtml> </routers> </admin> </config> [/sourcecode] Using above code you want to override any…
Read More

How to install magento on local server

Magento
Magento Installation | Magento Installation Process | Magento Installation On Localserver Step 1: Open php.ini file for apache C:/xampp/apache/bin/php.in Find php_curl.dll and remove comment(;) From the following line [sourcecode language="plain"]extension=php_curl.dll[/sourcecode] Same way make changes in C:/xampp/php/php.ini file Restart apache server from xampp control panel Step 2: If database connection error occurs "InnoDB Engine" Open file xampp\mysql\bin\my.cnf (Drag and Drop that file to Notepad or notepad++ program) Find code: [sourcecode language="plain"] # Comment the following if you are using InnoDB tables skip-innodb #innodb_data_home_dir = "/xampplite/mysql/" #innodb_data_file_path = ibdata1:10M:autoextend #innodb_log_group_home_dir = "/xampplite/mysql/" #innodb_log_arch_dir = "/xampplite/mysql/" ## You can set .._buffer_pool_size up to 50 - 80 % ## of RAM but beware of setting memory usage too high #innodb_buffer_pool_size = 16M #innodb_additional_mem_pool_size = 2M ## Set .._log_file_size to 25 % of buffer pool…
Read More

Magento Invalid Method Mage Catalog Model Product IsDuplicable

Magento
New version theme is not working in old version. After upgrading magento or when I design theme in magento 1.5.0.1 and use that theme in magento 1.4.2 that time my product page shows error like Invalid method Mage_Catalog_Model_Product::isDuplicable I find the solutin and its work for me. Copy your product.php file from this path: app\code\core\Mage\Catalog\Model\product.php and replace in your maegnto folder. [JWD-Magento-Development]
Read More

Call to undefined method Mage_Adminhtml_Block_Widget::getrowurl

Magento
If you install new magento or upgrade your magento with latest version or you got the error like below: Fatal error: Call to undefined method Mage_Adminhtml_Block_Widget::getrowurl() in C:\xampp\htdocs\magento\app\code\core\Mage\Adminhtml\Block\Widget\Grid.php on line 1622 Read this for the solution that workes for me: Go To app/code/core/Mage/Adminhtml/Block/Widget/Grid.php Look at on line no 1620 on magento 1.5.01 public function getRowUrl($item) { $res = parent::getRowUrl($item); return ($res ? $res : '#'); } And replace this line $res = parent::getRowUrl($item); to $res = parent::getUrl($item); So your new function look like this: public function getRowUrl($item) { $res = parent::getUrl($item); return ($res ? $res : '#'); } [JWD-Magento-Development]
Read More