Today I needed to exclude hot products and recently viewed products block from homepage, so I needed to find if the current page is homepage. The first block of code worked on header.phtml template but not in main page template, so I ended up using 2nd option.
If you need to check this on header.phtml template then use this code:
We not only created a lot of new categories, we deleted a lot of old categories and renamed some of them as well. Now the issue was to correctly assigning products to appropriate categories. We were provided product csv with three columns (category,sku,category-code). category-code was for SAP admins, so they can update their inventory according to code. But we need other two columns only. Here is the shell script I wrote which runs smoothly and does the work for me :-)
Some of our simple products were not correctly assigned to a configurable product. And, some of them were visible independently in the front end. My task was to assign simple products to correct configurable product and make associated products to not visible individually. It was easy to find configurable product and associated simple products because of the SKU they had. All simple products had sku configurableSKU__*.