Tuesday, February 17, 2015

How to show custom collection with layered navigation in Magento ?

Sometime you need to show all special price products collection or any custom product collection of any categories, under selected category (eg. Special) with layered navigation.

copy /app/code/core/Mage/Catalog/Model/Layer.php to /app/code/local/Mage/Catalog/Model/Layer.php

Go to line# 97

Replace following function code

public function getProductCollection()
    {
        if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) {
            $collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
        } else {
            $collection = $this->getCurrentCategory()->getProductCollection();
            $this->prepareProductCollection($collection);
            $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
        }

        return $collection;
    }

with

public function getProductCollection()
    {
        if (isset($this->_productCollections[$this->getCurrentCategory()->getId()]))
        {
            $collection = $this->_productCollections[$this->getCurrentCategory()->getId()];
        }
    else
    {
        //custom code start
        if($this->getCurrentCategory()->getId() == '228')
        {
            $collection = Mage::getResourceModel('catalog/product_collection');
            $todayDate = date('m/d/y');
            $tomorrow = mktime(0, 0, 0, date('m'), date('d'), date('y'));
            $tomorrowDate = date('m/d/y', $tomorrow);

            $collection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))
                ->addAttributeToFilter('special_to_date', array('or'=> array(
                    0 => array('date' => true, 'from' => $tomorrowDate),
                    1 => array('is' => new Zend_Db_Expr('null')))
                ), 'left');

            $this->prepareProductCollection($collection);
            $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
        //custom code end
        }

        else
        {

            $collection = $this->getCurrentCategory()->getProductCollection();
            $this->prepareProductCollection($collection);
            $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection;
        }

    }

Enjoy!!!

Re-Index Data With Command Shell

Magento uses a lot of resources to re-index data from the Admin Panel. A good way to re-index data without using the admin panel is to use command shell “ssh”. This also would work if you happen to be locked out of the admin panel.



Here is instruction on how to use default Magento indexer via SSH:

1 – Go to ‘shell’ folder in your Magento installation:

cd shell                                           

2 – Execute reindex using this command:

php -f indexer.php reindexall                      

It is possible to get full list of Magento indexer commands using this command:

php -f indexer.php help                            

To get a list of available indexes, execute this command:
 
php -f indexer.php info                            
 

By default there are 8 indexes in Magento:

catalog_product_attribute     Product Attributes   
catalog_product_price         Product Prices       
catalog_url                   Catalog Url Rewrites 
catalog_product_flat          Product Flat Data    
catalog_category_flat         Category Flat Data   
catalog_category_product      Category Products    
catalogsearch_fulltext        Catalog Search Index 
cataloginventory_stock        Stock status         

Individual commands for re-indexing:

php indexer.php --reindex catalog_product_attribute
php indexer.php --reindex catalog_product_price    
php indexer.php --reindex catalog_url              
php indexer.php --reindex catalog_product_flat     
php indexer.php --reindex catalog_category_flat    
php indexer.php --reindex catalog_category_product 
php indexer.php --reindex catalogsearch_fulltext   
php indexer.php --reindex cataloginventory_stock   
php indexer.php --reindex tag_summary              
 

Usefull SSH commands for magento developer.

Create zip file of folder via SSH.
    tar czvf <filename.tar.gz> <DIRECTORY or DIRECTORY PATH>

Extract zip file to particular destination folder.
    unzip file.zip -d destination_folder   

Change file permission
  chmod -r 777 filename

Friday, February 6, 2015

How to import sql file into using shell in windows xampp ?






Method 1

Open shell from xampp control panel.






Type  
cd mysql/bin

Press enter & type
mysql -u root -p db_name

It will ask for password so type your password. if it is critical to type then please use copy paste tool.


Type  
source filepath/filename.sql


eg. source c:\db_filename.sql


Any query welcome!!

Tuesday, February 3, 2015

Scope of Information Technology in coming future

We all know that the world had become impossible to move without Information Technology. The technologies are developing day by day. The fast growth in technological field had made the world a better and fast moving place. The growth is due to the increase in applications of computers in almost every field. Today in this article I am going to express ideas about Information Technology in front of you.

Introduction

The term Information Technology refers to the application of technology by considering an information. The storing, manipulation and management of data using computer can also be defined as an Information Technology. The IT sector has grown much faster globally. Today even India is standing as a developing country due to this vast growth in IT sector. The vacancies in IT professions are also increasing due to the variety of performance of IT professionals in every fields. The above mentioned reason also force IT industries to provide employments upon a large scale. The different small branches of IT such as Database Management, Networking, Information, Security, Cloud Computing, Business Intelligence etc are also increasing day by day.

Advantage in IT

IT sector can be said as a pot of chances that give one many opportunities to reach top in his/her life. The main specialty of this field is that one can reach his success by just having some qualities like creativity, willpower to learn new things, ability to withstand any situations and confidence.

Everyone use to dream a house in his 35th age, a car in 40 and an excellent retirement amount of 10-15 lakhs in his/her account. But a talented IT professional can acquire those dreams within his 30's. Even a government employer may take years of experience to get increment in his/her salary and post, but here in IT sector it just take some months to get it.

IT also help a professional to get fixed his meetings abroad, this help him to get job opportunities in many foreign companies and it will definitely make his world immense. IT also helps in increasing one`s talent and personality.

Career in Information Technology

IT students have a lot of scope for their future. Since the technologies and IT sectors are increasing day by day, the need of employers are also increasing. But just reaching IT field for the sake of a degree and a job wont give success. Because in coming future the IT industries do not adopt employers having degrees for a short term course, they need really talented and well experienced employers to do their job.

Job security in IT

At one side there are huge chances but one of the main drawback of this field is that it does not provide any job security. We cannot predict whether our job or even company will be there tomorrow. Even though the IT job don`t last longer, there is a hope for getting another job in the same field. There will be no problem for those who are having experience certificate, in case of job loss.

Conclusion

No doubt that IT fields are in its developing path. There will never be any degrading in its opportunities. IT may be the best field for those searching for self employments. If you are able to get success in your IT courses, then I can guarantee that your dreams will never die. The scope of IT field will continue increasing even on next decades.

This article found me on GOOGLE.  I thought to share all of you.