Php 如何在magento中获取当前愿望列表

Php 如何在magento中获取当前愿望列表,php,magento,Php,Magento,伙计们,抱歉英语不好。 我在Magento enterprise中使用,我在wishlist中工作,在path的core中有一个函数 C:\xampp\htdocs\projects\baab.bh\app\code\core\Mage\Wishlist\Helper\Data.php 当我调用此函数从前端phtml文件获取愿望列表时,它给了我正确的愿望列表,但当我从控制器调用此函数时,它只给了我默认的愿望列表,而不是当前的愿望列表。这里是此函数的代码 public function getWi

伙计们,抱歉英语不好。 我在Magento enterprise中使用,我在wishlist中工作,在path的core中有一个函数

C:\xampp\htdocs\projects\baab.bh\app\code\core\Mage\Wishlist\Helper\Data.php

当我调用此函数从前端phtml文件获取愿望列表时,它给了我正确的愿望列表,但当我从控制器调用此函数时,它只给了我默认的愿望列表,而不是当前的愿望列表。这里是此函数的代码

public function getWishlist()
    {
        if (is_null($this->_wishlist)) {
            if (Mage::registry('shared_wishlist')) {
                $this->_wishlist = Mage::registry('shared_wishlist');
            } elseif (Mage::registry('wishlist')) {
                $this->_wishlist = Mage::registry('wishlist');
            } else {
                $this->_wishlist = Mage::getModel('wishlist/wishlist');
                if ($this->getCustomer()) {
                    $this->_wishlist->loadByCustomer($this->getCustomer());
                }
            }
        }
        return $this->_wishlist;
    }

我用相同的代码调用它,但它的行为与前端phtml文件和控制器不同。如何从控制器获取当前愿望列表?

为此,您将获取所有客户的愿望列表:

public function getWishlist()
{
    $customer = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');

    $wishList = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer);
    $wishListAllItem = $wishList->getItemCollection();

    if (count($wishListAllItem)) {
        $arrOfProductIds = array();

        foreach ($wishListAllItem as $item) {
            $arrOfProductIds[] = $item->getProductId();
        }
    }

    return $arrOfProductIds;
}
$wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($customer)
$wishListAllItem = $wishList->getItemCollection();

if (count($wishListAllItem)) {
    $arrOfProductIds = array();

    foreach ($wishListAllItem as $item) {
        $product = $item->getProduct();
        $arrOfProductIds[] = $product->getId();
    }
}
为此,您可以获取当前用户愿望列表:

public function getWishlist()
{
    $customer = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');

    $wishList = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer);
    $wishListAllItem = $wishList->getItemCollection();

    if (count($wishListAllItem)) {
        $arrOfProductIds = array();

        foreach ($wishListAllItem as $item) {
            $arrOfProductIds[] = $item->getProductId();
        }
    }

    return $arrOfProductIds;
}
$wishList = Mage::getSingleton('wishlist/wishlist')->loadByCustomer($customer)
$wishListAllItem = $wishList->getItemCollection();

if (count($wishListAllItem)) {
    $arrOfProductIds = array();

    foreach ($wishListAllItem as $item) {
        $product = $item->getProduct();
        $arrOfProductIds[] = $product->getId();
    }
}

当前用户愿望列表?我在愿望列表页面,我需要当前愿望列表对象,我需要愿望列表名称,但我不想要收藏,伙计,我只需要当前愿望列表name@OBAID当用户单击愿望列表时,是否希望获得当前的愿望列表名称?我说的对吗?实际上我在愿望列表页面中有一个按钮,当用户单击它时,它会向该函数发送一个ajax,我需要这个愿望列表对象