Magento 1.9.2.3 - Wishlist issue
-
01-10-2020 - |
Question
I would like to ask you some help regarding an issue I'm having in the wishlist section. When we add a product as favourite, this message appears as an error.
Fatal error: Call to a member function setItems() on boolean in /home2/***/public_html/app/design/frontend/base/sinprecio/template/wishlist/view.phtml on line 43
This is the code in the view.phtml
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<div class="my-wishlist">
<div class="page-title title-buttons">
<?php if ($this->helper('wishlist')->isRssAllow() && $this->hasWishlistItems()): ?>
<a href="<?php echo $this->helper('wishlist')->getRssUrl($this->getWishlistInstance()->getId()); ?>" class="link-rss"><?php echo $this->__('RSS Feed') ?></a>
<?php endif; ?>
<h1><?php echo $this->getTitle(); ?></h1>
</div>
<?php echo $this->getMessagesBlock()->toHtml() ?>
<form id="wishlist-view-form" action="<?php echo $this->getUrl('*/*/update', array('wishlist_id' => $this->getWishlistInstance()->getId())) ?>" method="post">
<?php echo $this->getChildHtml('top'); ?>
<fieldset>
<?php if ($this->hasWishlistItems()): ?>
<?php echo $this->getBlockHtml('formkey');?>
<?php $this->getChild('items')->setItems($this->getWishlistItems()); ?>
<?php echo $this->getChildHtml('items');?>
<script type="text/javascript">decorateTable('wishlist-table')</script>
<?php else: ?>
<p class="wishlist-empty"><?php echo $this->__('You have no items in your wishlist.') ?></p>
<?php endif ?>
<div class="buttons-set buttons-set2">
<?php echo $this->getChild('control_buttons')->toHtml();?>
</div>
</fieldset>
</form>
<form id="wishlist-allcart-form" action="<?php echo $this->getUrl('*/*/allcart') ?>" method="post">
<?php echo $this->getBlockHtml('formkey') ?>
<div class="no-display">
<input type="hidden" name="wishlist_id" id="wishlist_id" value="<?php echo $this->getWishlistInstance()->getId() ?>" />
<input type="hidden" name="qty" id="qty" value="" />
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var wishlistForm = new Validation($('wishlist-view-form'));
var wishlistAllCartForm = new Validation($('wishlist-allcart-form'));
function calculateQty() {
var itemQtys = new Array();
$$('#wishlist-view-form .qty').each(
function (input, index) {
var idxStr = input.name;
var idx = idxStr.replace( /[^\d.]/g, '' );
itemQtys[idx] = input.value;
}
);
$$('#qty')[0].value = JSON.stringify(itemQtys);
}
function addAllWItemsToCart() {
calculateQty();
wishlistAllCartForm.form.submit();
}
//]]>
</script>
</div>
<?php echo $this->getChildHtml('bottom'); ?>
<div class="buttons-set">
<p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>« </small><?php echo $this->__('Back') ?></a></p>
</div>
And this is the line 43
<?php $this->getChild('items')->setItems($this->getWishlistItems()); ?>
Any clue? I'm kinda lost with this error. Thanks in advance!
Solution
You need to find how the items
block is set as child of the parent block instance (the $this
in the template).
You did a good job to include the related template code, but unfortunately $this->getChild('items')
refers to a child block which isn't being set by layout XML (or some programmatic method). This means there is missing context, and providing all of that context here is likely impossible.
If this is a third-party theme, refer to their support channel.
OTHER TIPS
Please check wishlist.xml
in your current theme. If it exists in your theme then compare it with app/design/frontend/base/default/layout/wishlist.xml
and make necessary updates, your wishlist.xml should have code something like:
<wishlist_index_index translate="label">
<label>Customer My Account My Wishlist</label>
<!-- Mage_Wishlist -->
<update handle="customer_account" />
<reference name="my.account.wrapper">
<block type="wishlist/customer_wishlist" name="customer.wishlist" template="wishlist/view.phtml">
<action method="setTitle" translate="title">
<title>My Wishlist</title>
</action>
<block type="wishlist/customer_wishlist_items" name="customer.wishlist.items" as="items" template="wishlist/item/list.phtml">
<block type="wishlist/customer_wishlist_item_column_image" name="customer.wishlist.item.image" template="wishlist/item/column/image.phtml" />
<block type="wishlist/customer_wishlist_item_column_comment" name="customer.wishlist.item.info" template="wishlist/item/column/info.phtml">
<action method="setTitle" translate="title">
<title>Product Details and Comment</title>
</action>
</block>
<block type="wishlist/customer_wishlist_item_column_cart" name="customer.wishlist.item.cart" template="wishlist/item/column/cart.phtml">
<action method="setTitle" translate="title">
<title>Add to Cart</title>
</action>
<block type="wishlist/customer_wishlist_item_options" name="customer.wishlist.item.options" />
</block>
<block type="wishlist/customer_wishlist_item_column_remove" name="customer.wishlist.item.remove" template="wishlist/item/column/remove.phtml" />
</block>
<block type="core/text_list" name="customer.wishlist.buttons" as="control_buttons">
<block type="wishlist/customer_wishlist_button" name="customer.wishlist.button.share" template="wishlist/button/share.phtml" />
<block type="wishlist/customer_wishlist_button" name="customer.wishlist.button.toCart" template="wishlist/button/tocart.phtml" />
<block type="wishlist/customer_wishlist_button" name="customer.wishlist.button.update" template="wishlist/button/update.phtml" />
</block>
</block>
</reference>
<reference name="right">
<action method="unsetChild"><name>wishlist_customer_sidebar</name></action>
</reference>
</wishlist_index_index>
so, if your theme name is is under app/design/frontend/default/theme001/
then you should look for wishlist.xml
in app/design/frontend/default/theme001/
directory and update it according to xml one in base/default theme
Hope it will work, because it worked for me!