Chandan Web Blog.

Adding search by Category feature to Magento Advanced search and catlog search in Product list view

I recently had to add a search form in the Magento product list view and I found the following Wiki article:

http://www.magentocommerce.com/wiki/how-to/how_to_add_search_by_category_to_advanced_search

This article would work 100% perfect, however the steps given in article is not really upgrade safe.

There were hence two options either to include these steps in a seperate magento module, or to follow the steps I have given here.
This is not really a perfect practice, however, if we are not aware of writing a magento module then this can be a very quick alternative.
This step also protects us from our work being over-written when we make a magento upgrade.

Step 1:
Create a new folder called “Mage” inside app/code/local

Now we have anew folder app/code/local/Mage

Step 2:
If I see the steps given in Magento wiki, we notice that the they are extending the features of the CatalogSearch module that is located in the namespace Mage,
So just go to “app/code/core/Mage” and copy the entire folder named “CatalogSearch” into app/code/local/Mage

Now we have the entire “CatalogSearch” module located in app/code/local/Mage/CatalogSearch

Step 3:
Now all we need to do is follow the exact steps given in the wiki article, however make sure to edit files located in app/code/local/Mage/CatalogSearch only.

Link to the wiki: http://www.magentocommerce.com/wiki/how-to/how_to_add_search_by_category_to_advanced_search

How to add catalog search in Magento product list view or the Search by category feature in Magento product list view.

This simply involves adding a search form in prodcut list view we however need to ensure that the category id is passed to the advanced search form using a hidden input.

Add the following code to

“app\design\frontend\YOURPACKAGENAME\default\template\catalog\product\list\toolbar.phtml”
OR
“app\design\frontend\YOURPACKAGENAME\default\template\catalog\product\list.phtml”

<?php if( !isset($_GET['category']) ): ?>
<form action=”<?echo $this->getUrl(‘catalogsearch/advanced/result’)?>” method=”get” id=”category_search_form”>
<?php

if ($this->helper(‘catalog/data’)->getCategory()) {
$_ccat = $this->helper(‘catalog/data’)->getCategory();
} else {
$_ccats = $this->helper(‘catalog/data’)->getProduct()->getCategoryIds();
$_ccat = Mage::getModel(‘catalog/category’)->load($_ccats[0]);
};
$_ccatID = $_ccat->getId();
?>
<input type=”hidden” id=”category_search_field” name=”category” value=”<?php echo $_ccatID ?>” />
<div class=”left”>
<input name=”name” id=”searchcat” value=”<?php echo $this->__(‘Search Category’) ?>” title=”Name” class=”input-text ” type=”text” />
<input type=”image” alt=”<?php echo $this->__(‘Search’) ?>” src=”<?php echo $this->getSkinUrl(images/ico_s_search.png’)?>” class=”cw_buttonicon” />
</div>
</form>
<script type=”text/javascript”>
//<![CDATA[
var searchForm = new Varien.searchForm('category_search_form', 'searchcat', '<?php echo $this->__('Search Category') ?>');
searchForm.initAutocomplete('<?php echo $this->helper('catalogSearch')->getSuggestUrl() ?>', 'search_autocomplete');
//]]>
</script>
<?php endif ?>

Note:
1.The first if statement <?php if( !isset($_GET['category']) ): ?> makes sure that we will not have two forms in the advanced search result page.
You should retain this if statement because when we are in advanced search we will no longer be in the previously selected category!

2.
You may need to change the path of search image.

3. I have also included the autocomplete feature, so be careful if you are changing the name or ID attribute of the form or the input tags.

Hope this article would be useful, kindly do not forget to write your comments here. Thank you.

Link to Top re-directs to home page.

If link to top is re-directs to homepage, to solve this we have to include following code int to our  typo-script setup page

config {
prefixLocalAnchors = all
}

This  replaces  all links like <a href=”#” > into <a href=”[url]#”>

SVN Errorcode 13 due to SeLinux, Could not open the requested SVN filesystem

When we recently installed SVN on CentOS, we came across the following error message:

<m:human-readable errcode=”13″>Could not open the requested SVN filesystem</m:human-readable>

This seems to be due to incorrect setting of the SeLinux content. This can be changed by the following command:

chcon -R -h -t httpd_sys_content_t /PATH_TO_REPOSITORY/

ex:

chcon -R -h -t httpd_sys_content_t /home/svnRepo

Technorati : , ,
Del.icio.us : , ,

Upgrade SVN Server to 1.6.5 on XAMPP

This is a quick help guide for all thise who would like to upgrade to latest SVN on XAMPP.

NOTE: Like with all software upgrades there could be high risk involved.
It is always better to take a backup prior to proceeding with any kind of upgrades.

We know that when a latest version of SVN is around it is time to upgrade.
If you have already customized your XAMPP it is not an easy task to upgrade XAMPP as it might waste several days of your work!

I however came up with a quick solution to this issue. SVN binaries are stored in the \xampp\apache\bin folder.
If you closely observe this folder you can find these binaries and there are also several related DLL files.

Now we know where the files are, and it is time to grab the latest SVN binaries and proceed to upgrade.

  1. Go to http://subversion.tigris.org/ and click on Windows Binaries link.


  2. Now select Tigris.org

  3. Select the “Subversion Win32 binaries for Apache 2.2.x”

  4. Extract these file to some temporary location on your PC, and you can see a lot of exe and dll files inside the bin folder!
    I noticed 40 files in SVN 1.6.5!
  5. Now it is time to back up the existing files. Stop Apache prior to backup.
  6. I used 7zip and created a zip file of entire bin folder. This saved me a lot of time in trying to find all SVN related files.

  7. Now you already have a bckup, and you can simply copy the latest SVN binaries from the temporary SVN bin folder to the xampp/apache/bin folder.
  8. Restart Apache and check if SVN is working fine now. This should work perfect.

I hope this would be useful. Please send yor comments / queries in case of any issues.

Del.icio.us : , , ,
Technorati : , , ,

Assigning a Favicon or Shortcuticon in Typo3 using Typoscript for multiple domains

Assigning a favicon is quite simple in Typo3. you can just use the following Typoscript to assign a favicon.

page.shortcutIcon = pathToFolders/favicon.ico

In case of multi-domain setup there are various ways you can achive this:

1. By adding the above code in the Typoscript Template Record of root page for each domain.

2. If same root page is used used for 2 domains we can write a conditional statement and check the domain, and change the Favicon.

[globalString = ENV:HTTP_HOST = *mydomain.com]

page.shortcutIcon = pathToFolders/favicon.ico

[global]

[globalString = ENV:HTTP_HOST = *myotherdomain.com]
page.shortcutIcon = pathToFolders/favicon2.ico

[global]

Subscribe to this page grab our RSS feed
Theme & Wordpress Integration - by Chandan