|
I’m glad I’m not the only one that was frustrated with this - and thanks to a combination of some tips in the posts above and some trial-and-error hacking, I think I have finally cracked it! That said, I’m a complete newbie to both Magento and php programming, so if anyone knows of a more elegant solution, I’d be very glad to hear about it…
To remove all of the references to product compares, there are a lot of files to edit in your app/.../theme directory tree. In fact they are all in the {theme}/template/category/product directory path (I think). There are two types of modification to make :
1. Files that list products, where the “Add to Compare” must be disabled
- {theme/.../product}/list.phtml
- {theme/.../product}/new.phtml
- {theme/.../product}/view/bundle.phtml
- {theme/.../product}/view/type/configurable.phtml
- {theme/.../product}/view/type/grouped.phtml
- {theme/.../product}/view/type/simple.phtml
In all of these files, the objective is to comment out the code creating the “Add to Compare” link.
To do this, open the files in your favourite code editor, search for “compare”, and place an HTML comment around the php code that creates the unwanted link. To be doubly sure, you can add a false&& into any conditional clauses you find. Of course, either of these two methods will work on their own - and you could also remove the code altogether, but that would make it harder to reinstate at a later point.
For example, in list.phtml, I change the code :
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)): ?> <span class="pipe">|</span> <a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a> <?php endif; ?>
...to…
<!-- START OF COMMENT *** false added to condition below, to force out compare (and HTML comment spans it also) <?php if(false&&$_compareUrl=$this->getAddToCompareUrl($_product)): ?> <span class="pipe">|</span> <a href="<?php echo $_compareUrl ?>"><?php echo $this->__('Add to Compare') ?></a> <?php endif; ?> *** END OF COMMENT -->
*** NOTE - not all occurrences of the word ‘compare’ need to be removed ***
2. Files that present the list of compared items. Two files :
- {theme/.../product}/compare/list.phtml - no change really required, as this page can no longer be reached, but when I have a more elegant solution, this will need adjusting also.
- {theme/.../product}/compare/sidebar.phtml - which produces the compare box in the sidebar.
Basically I just create a condition around the code that blocks all output:
At the start of the file (between the header comments and the first <div> statement, insert the line :
<?php if(false): ?>
... and close this at the end of the code (very last line):
<?php endif; ?>
... et voila! Let me know how you get on.
I’m looking into a better way, to control this all via the admin screens (or at least the database) in a similar way to the Wishlist. Will update you all on this in due course…
David
|