Magento: change toplink wishlist url - magento

I am trying to change Magento toplink wishlist button url.
At the moment it is generated in wishlist.xml with
<reference name="top.links">
<block type="wishlist/links" name="wishlist_link" />
<action method="addLinkBlock"><blockName>wishlist_link</blockName></action>
</reference>
This leads me to merry chase in core files with no result.
What I want to do is for the button to direct to /guestwishlist/ instead of /wishlist/ (which in addition atm, for some reason leads to wishlist/index/share).
I've read most of the relevant guides and answers since worked on it for hours.
Just need to change that single button url to go to /guestwishlist/.
EDIT>
This is how my top.links.phtml looks like
<?php if($toplinks && is_array($toplinks)): ?>
<ul class="links">
<?php echo $this->getChildHtml() ?>
<?php foreach($toplinks as $_toplink): ?>
<li<?php if($_toplink['first']||$_toplink['last']): ?> class="<?php if($_toplink['first']): ?>first<?php endif; ?><?php if($_toplink['last']): ?> last<?php endif; ?>"<?php endif; ?> <?php echo $_toplink['liParams'] ?>><?php echo $_toplink['beforeText'] ?><a <?php echo $_toplink['aParams'] ?>><?php echo $_toplink['innerText'] ?></a><?php echo $_toplink['afterText'] ?></li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

You can change the wishlist url to custom url by editing template/page/html/top.links.phtml
There is a foreach in which you can check if current looping item is wishlist, change the default url to your custom URL.
This will make sure whatever changes you are making are only limited to frontend rendering of content and also no need to override any core files.

To change wishlist url in proper magento way you need to override:
app/code/core/Mage/Wishlist/Block/Links.php
in local or community codePool.
In this file you will find code like this:
protected function _toHtml()
{
if ($this->helper('wishlist')->isAllow()) {
$text = $this->_createLabel($this->_getItemCount());
$this->_label = $text;
$this->_title = $text;
$this->_url = $this->getUrl('wishlist');
return parent::_toHtml();
}
return '';
}
Change
$this->_url = $this->getUrl('wishlist');
to
$this->_url = $this->getUrl('guestwishlist');
and you are done.. :)
Now you must create or have a module for guestwishlist.

The core solution works yeah but I had to keep in mind that I only want to change the link for guests, for customers the link had to stay the same.
Specifics to my site used the template/page/links.phtml file instead of top.links.phtml mentioned by Blastfreak so I had to two everything twice :P
I used the solution of checking for the current item in loop.
<ul class="links"<?php if($this->getName()): ?> id="<?php echo $this->getName() ?>"<?php endif;?>>
<?php foreach($_links as $_link): ?>
<?php if ($_link instanceof Mage_Core_Block_Abstract):?>
<?php if ($_link->gettype() == 'wishlist/links' && (!$this->helper('customer')->isLoggedIn())): ?>
<?php echo '<li class="first last">My Wishlist</li>' ?>
<?php else: ?>
<?php echo $_link->toHtml() ?>
<?php endif;?>
<?php else: ?>
<li<?php if($_link->getIsFirst()||$_link->getIsLast()): ?> class="<?php if($_link->getIsFirst()): ?>first<?php endif; ?><?php if($_link->getIsLast()): ?> last<?php endif; ?>"<?php endif; ?> <?php echo $_link->getLiParams() ?>><?php echo $_link->getBeforeText() ?><a href="<?php echo $_link->getUrl() ?>" title="<?php echo $_link->getTitle() ?>" <?php echo $_link->getAParams() ?>><?php echo $_link->getLabel() ?></a><?php echo $_link->getAfterText() ?></li>
<?php endif;?>
<?php endforeach; ?>
</ul>
Had to echo some extra classes for style.

Related

Magento removing item options in checkout order review section

In my website i have enable one page checkout.Also there are only downloadable products.
I need to remove Item options in Checkout Order Review section (Please refer below image. I need to remove highlighted parts.)
Can anyone let me know how to do this please.
Thank You.
I think you want to remove custom option in checkout.
The custom options are displayed in the default template (in \app\design\frontend\base\default\template\checkout\cart\item\default.phtml) with the following snippet:
<?php if ($_options = $this->getOptionList()):?>
<dl class="item-options">
<?php foreach ($_options as $_option) : ?>
<?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
<dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
<dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
<?php if (isset($_formatedOptionValue['full_view'])): ?>
<div class="truncated_full_value">
<dl class="item-options">
<dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
<dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
</dl>
</div>
<?php endif; ?>
</dd>
<?php endforeach; ?>
</dl>
<?php endif;?>
So, you comment this or remove as per your convenience.
But in your case you are using onepage checkout So, you have to check this code in extensions phtml file.
You need to go in app\design\frontend\rwd\default\template\downloadable\checkout\onepage\review\item.phtml
Open item.phtml file
And in this file here is code what is displaying that
<?php if ($links = $this->getLinks()): ?>
<dl class="item-options">
<dt><?php echo $this->getLinksTitle() ?></dt>
<?php foreach ($links as $link): ?>
<dd><?php echo $this->escapeHtml($link->getTitle()); ?></dd>
<?php endforeach; ?>
</dl>
<?php endif; ?>
So you can remove or just comment this <!--<dl>...</dl>--> and you will get you want.
And yes go to your theme folder if your is not rwd.

hide wishlist button if item is already in wishlist in magento

Magento ver. 1.9.1.0 .
hide wishlist button if item is already in current customers wishlist or change it to filled heart
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<div class="ajax-wishlist">
<a href="#"
onclick='ajaxWishlist("<?php echo $this->helper('wishlist')->getAddUrl($_product) ?>","<?php echo $_product->getId()?>");return false;' class="link-wishlist" title="Add to Wishlist">
<i class="fa fa-heart-o"></i>
</a>
</div>
<?php endif; ?>
further i would like to update wishlist button dynamically. ie fa-heart-o TO fa-heart as soon as wishlist is updated..
[new to magento]
reference Check whether a product is in the wishlist or not
I tried this.
<?php $wishlist = Mage::getModel('wishlist/item')->load($_product->getId(),'product_id');
if($wishlist->getId())
//product is added
echo "Added! - Product is in the wishlist!";
else
//add product to wishlist
echo "<a href='".$this->helper('wishlist')->getAddUrl($_product) ."'>Add This?</a>";
;?>
It shows all products that have been added to the wishlist by any customers.
and how to use above code for homepage products? ie new arrival, most viewed etc. It shows error.call to a member function getId() on non object
If you need to check if a product is in the wishlist and display that information instead of the default Magento “Add to Wishlist” link, this article is for you. To simplify things I will explain how to detect if a product is in the wishlist on category and product page but the principle is the same for any other pager or block. You just need to be sure that you have the product id available. Everything else should work fine on any page.
Category page
Open template/catalog/product/list.phtml
Find the wishlist link code. If you are using the base theme it should look something like this:
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><?php echo $this->__('Add to Wishlist') ?></li>
<?php endif; ?>
Replace it with:
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<?php foreach (Mage::helper('wishlist')->getWishlistItemCollection() as $_wishlist_item): ?>
<?php $_in_wishlist = false; ?>
<?php if($_product->getId() == $_wishlist_item->getProduct()->getId()): ?>
<?php $_in_wishlist = true; break; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php if(!empty($_in_wishlist) && $_in_wishlist): ?>
<li><span class="in-wishlist"><?php echo $this->__('Already in Wishlist') ?></span></li>
<?php else: ?>
<li><?php echo $this->__('Add to Wishlist') ?></li>
<?php endif; ?>
<?php endif; ?>
Product page
Open template/catalog/product/view/addto.phtml
Find the wishlist link code. If you are using the base theme it should look something like this:
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<li><?php echo $this->__('Add to Wishlist') ?></li>
<?php endif; ?>
Replace it with:
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<?php foreach (Mage::helper('wishlist')->getWishlistItemCollection() as $_wishlist_item): ?>
<?php $_in_wishlist = false; ?>
<?php if($_product->getId() == $_wishlist_item->getProduct()->getId()): ?>
<?php $_in_wishlist = true; break; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php if(!empty($_in_wishlist) && $_in_wishlist): ?>
<li><span class="is-wishlist"><?php echo $this->__('Already in Wishlist') ?></span></li>
<?php else: ?>
<li><?php echo $this->__('Add to Wishlist') ?></li>
<?php endif; ?>
<?php endif; ?>
That’s it. As I said above you can use this method to check if the product is in the wishlist on any Magento page or block as long as you have a product id available.

Magento - Remove Category from shopping option block from left side bar

Before posting this question I have tried my best to find solution for this. I want to remove category layer from the shopping option block on left sidebar of magento.
http://i59.tinypic.com/35mi22u.jpg
I want to remove the marked option from my left sidebar. I need price and color to appear.
Any help appreciated.
Thanks in Advance.
my app/design/frontend/default/default/template/catalog/layer/view.phtml
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php $i=0; foreach ($_filters as $_filter): $i++; ?>
<?php if($_filter->getItemsCount()): ?>
<dt id="filterlabel<?php echo $i;?>"><?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<script type="text/javascript" >
<?php if($open == 1): ?>
jQuery('#filterlabel<?php echo $i;?>').each(function(){
jQuery(this).addClass('active');
jQuery(this).toggle(function(){
jQuery(this).removeClass('active').next().slideUp(200);
},function(){
jQuery(this).addClass('active').next().slideDown(200);
})
});
<?php elseif($open == 0): ?>
jQuery('#filterlabel<?php echo $i;?>').each(function(){
jQuery(this).next().hide();
jQuery(this).toggle(function(){
jQuery(this).addClass('active').next().slideDown(200);
},function(){
jQuery(this).removeClass('active').next().slideUp(200);
})
});
<?php endif; ?>
</script>
<?php endif; ?>
<?php endforeach; ?>
</dl>
In your theme catalog.xml file replace
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
with
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml">
<action method="unsetChild"><child>category_filter</child></action>
</block>
This is what I did to remove the “Category” section from my layered navigation
so I wouldnt have any repeat information with the attributes
I wanted in the layered navigation.
go to app/design/frontend/default/default/template/catalog/layer and open up view.phtml for edit.
<dl id="narrow-by-list">
<?php $_filters = $this->getFilters() ?>
<?php $i=0; foreach ($_filters as $_filter): $i++; ?>
<?php if($_filter->getItemsCount()): ?>
<?php if($_filter->getName() != "Category"){ ?>
<dt id="filterlabel<?php echo $i;?>">
<?php echo $this->__($_filter->getName()) ?></dt>
<dd><?php echo $_filter->getHtml() ?></dd>
<?php } endif; ?>
<script type="text/javascript" >
<?php if($open == 1): ?>
jQuery('#filterlabel<?php echo $i;?>').each(function(){
jQuery(this).addClass('active');
jQuery(this).toggle(function(){
jQuery(this).removeClass('active').next().slideUp(200);
},function(){
jQuery(this).addClass('active').next().slideDown(200);
})
});
<?php elseif($open == 0): ?>
jQuery('#filterlabel<?php echo $i;?>').each(function(){
jQuery(this).next().hide();
jQuery(this).toggle(function(){
jQuery(this).addClass('active').next().slideDown(200);
},function(){
jQuery(this).removeClass('active').next().slideUp(200);
})
});
<?php endif; ?>
</script>
<?php endif; ?>
<?php endforeach; ?>
</dl>
After trying and fiddling with the code I managed to solve my problem.
Goto app/design/frontend/default/default/template/catalog/layer/view.phtml
Change:
<dt id="filterlabel<?php echo $i;?>"><?php echo $this->__($_filter->getName()) ?></dt>
to
<dt id="filterlabel<?php echo $i;?>"><?php if ($_filter->getName() != 'Category'): {?><?php echo $this->__($_filter->getName()) ?><?php } endif; ?></dt>
Here above I removed just the label 'Category' that is displayed in sidebar.
After that Goto app/design/frontend/default/default/template/catalog/layer/filter.phtml
Change:
<?php foreach ($this->getItems() as $_item): ?>
<li>
<?php if ($_item->getCount() > 0): ?>
<?php echo $_item->getLabel() ?>
<?php else: echo $_item->getLabel() ?>
<?php endif; ?>
<?php if ($this->shouldDisplayProductCount()): ?>
<!-- (<?php echo $_item->getCount() ?>)-->
<?php endif; ?>
</li>
<?php endforeach ?>
to
<?php foreach ($this->getItems() as $_item): ?>
<?php if ($this->getName() != 'Category'): {?>
<li>
<?php if ($_item->getCount() > 0): ?>
<?php echo $_item->getLabel() ?>
<?php else: echo $_item->getLabel() ?>
<?php endif; ?>
<?php if ($this->shouldDisplayProductCount()): ?>
<!-- (<?php echo $_item->getCount() ?>)-->
<?php endif; ?>
</li>
<?php } endif; ?>
<?php endforeach ?>
Here I removed the list that comes inside the Category layer.

How I get product options block in catalog

I did an quick view in product catalog (list.phtml) using Magento 1.7, but I'm unable to get the FULL product options block so that it is identical to the product page (showing select, radio button, select multiple, etc.). Can someone help me?
*Sorry for my bad English.
I tried put the view.phtml' code, but this don't work.
I also tried some tutorials that I found on google, but what worked converted all options in select, but I need to get entire block.
...
<?php if (!$this->hasOptions()):?>
<div class="add-to-box">
<?php if($_product->isSaleable()): ?>
<?php echo $this->getChildHtml('addtocart') ?>
<?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
<span class="or"><?php echo $this->__('OR') ?></span>
<?php endif; ?>
<?php endif; ?>
<?php echo $this->getChildHtml('addto') ?>
</div>
<?php endif; ?>
<?php echo $this->getChildHtml('other');?>
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
<?php endif;?>
...

how to write a custom panel displaying categories in magento

I have a category called "Top Products". I wish to display this in a panel on my home page. What is the best way to do this in magento.
** edit **
Thanks sdek, i now have the following. In Home Page / Design.
<block type="catalog/product_list" category_id="13" template="catalog/product/featured.phtml"/>
And it is displaying products. However i have the following issues.
- it's not displaying products from category_id 13, It seems like this value is not being passed thru
- it's only display 2 products. I wish to display all.
featured.phtml
<?php
$_productCollection=$this->getLoadedProductCollection();
$_helper = $this->helper('catalog/output');
?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<h2>Featured Products </h2>
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="product-grid">
<?php endif ?>
<li class="<?php if(($i-1)%$_columnCount==0): ?> first<?php else: ?> last<?php endif; ?>">
<a class="product-image" href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" >
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(85); ?>" class="product-img" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" style="padding-bottom:20px; margin-bottom:20px;" />
</a>
<p><strong><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></strong>
<?php echo $_product->getShortDescription(); ?></p>
<?php echo $this->getPriceHtml($_product, true) ?>
More details
</li>
<?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
</ul>
<?php endif ?>
<?php endforeach ?>
<?php endif; ?
I wouldn't even use a category but this extension instead:
Featured Products
The Featured Products extension mentioned by clockworkgeek is a good idea. But if you don't like that option the easiest thing to do is to add this in your home page cms
{{block type="catalog/product_list" category_id="YOUR_CAT_ID" template="catalog/product/YOUR_MODIFIED_COPY_OF_LIST.phtml"}}
And then make a copy of app/design/frontend///template/catalog/product/list.phtml (I refered to it above as YOUR_MODIFIED_COPY_OF_LIST.phtml) and remove the two lines that say
<?php echo $this->getToolbarHtml() ?>
and remove the entire if-block that outputs the "list mode"... basically the if statement
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
and you should only have the "grid mode" code in there.

Resources