1

Hi i'm not developer so please help. i'm trying to change 'My Wish List' to 'wishlist' and wanna remove 'items'

My Wish List 2 items - wishlist 2

1

3 Answers 3

5

To change the label for 'My Wish List' to 'wishlist' , go to vendor/magento/module-wishlist/i18n/your_language.csv (i think there will be en_us only) And change:

"My Wish List","My Wish List" 

to

"My Wish List","wishlist"

Okay, so if want to change as in the screenshot, goes to the same file and change this as you want.

"%1 items","%1 items" 

to

"%1 items","%1"

This will implement the change that you want, also you have to do in the line before that is "1 item","1 item"and remove the second item if you want to remove in case that there is only 1 item in the cart.

If you make the site multilanguage, don't forget to make the correct translations of this or this will appear in the other languages.

5
  • thank you i m working on new theme. please check screenshot awesomescreenshot.com/image/1253785/… is there any easy way to change on phtml or some file?
    – Rawi Rai
    Commented May 17, 2016 at 8:48
  • edited the response as you want.
    – ntzz
    Commented May 17, 2016 at 9:03
  • thank you @ntzz it works perfect. i've another question. how to re-order top links. My Account WishList Sign In to WishList My Account Sign In
    – Rawi Rai
    Commented May 17, 2016 at 14:01
  • @RawiRai as far as i know isn't possible. There is an issue with Magento 2 to make it possible, i had ask in github for it now, see on: github.com/magento/magento2/issues/2354
    – ntzz
    Commented May 17, 2016 at 14:34
  • Thanks for your answer. I don't want to make the csv edit in core module. How is it possible to extend the core file module .csv file.? Please help.
    – Vindhuja
    Commented Jun 8, 2017 at 6:30
1

You dont wanna write a preference if you can write a plugin like. You can download the module from this link https://mage2gen.com/load/31b0b02d-c02e-47ae-b6e1-bbd967930509 make sure to replace the plugin with code below.

namespace [Vendor]\Wishlist\Plugin\Magento\Wishlist\CustomerData;

class Wishlist
{

/**
 * @var \Magento\Wishlist\Helper\Data
 */
private $wishlistHelper;

/**
 * Wishlist constructor.
 * @param \Magento\Wishlist\Helper\Data $wishlistHelper
 */
public function __construct(
    \Magento\Wishlist\Helper\Data $wishlistHelper
) {
    $this->wishlistHelper = $wishlistHelper;
}

/**
 * {@inheritdoc}
 */
public function afterGetSectionData(
    \Magento\Wishlist\CustomerData\Wishlist $subject,
    $result
) {
    $result['counter'] = $this->wishlistHelper->getItemCount();
    return $result;
}
}
-1

Here is best way to archive this task.

'%1 items' text is coming from [createCounter] function from Wishlist class we only need to create preference for this.

\Magento\Wishlist\CustomerData\Wishlist

1.di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Wishlist\CustomerData\Wishlist" type="\Namespace\Modulename\CustomerData\Wishlist" />
</config>

Whishlist.php

 <?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Namespace\Modulename\CustomerData;


class Wishlist extends \Magento\Wishlist\CustomerData\Wishlist
{
   public function __construct(
       \Magento\Wishlist\Helper\Data $wishlistHelper,
       \Magento\Wishlist\Block\Customer\Sidebar $block,
       \Magento\Catalog\Helper\ImageFactory $imageHelperFactory,
       \Magento\Framework\App\ViewInterface $view
   ) {
       parent::__construct($wishlistHelper, $block, $imageHelperFactory, $view);
   }

    protected function createCounter($count)
    {
        if ($count > 1) {
            return __('%1', $count);
        } elseif ($count == 1) {
            return __('1');
        }
        return null;
    }
}

This one is the best way rather than changing in language file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.