English 中文(简体)
Magento - 获得客户希望名单
原标题:Magento - Accessing a customer s wishlist
  • 时间:2012-04-04 05:07:51
  •  标签:
  • magento

我希望能够装上客户的希望清单,并将产品贴出清单。

我正在使用:

$wishList = Mage::getSingleton( wishlist/wishlist )->loadByCustomer($customer);
$wishListItemCollection = $wishList->getItemCollection();

问题是,项目收集的阵列受到保护,我找不到任何方法提取数据。

是否有其他办法这样做?

最佳回答

你非常接近你们的目标。

$wishList = Mage::getSingleton( wishlist/wishlist )->loadByCustomer($customer);
$wishListItemCollection = $wishList->getItemCollection();

if (count($wishListItemCollection)) {
    $arrProductIds = array();

    foreach ($wishListItemCollection as $item) {
        /* @var $product Mage_Catalog_Model_Product */
        $product = $item->getProduct();
        $arrProductIds[] = $product->getId();
    }
}

阵列变数<代码> Ids现在将载有该特定客户希望列入的所有产品识别资料清单。

问题回答

你的法典是正确的。 可能没有装满客户。 这里是法典。

$customer = Mage::getSingleton( customer/session )->getCustomer();
$wishlist = Mage::getModel( wishlist/wishlist )->loadByCustomer($customer, true);
$wishListItemCollection = $wishlist->getItemCollection();

foreach ($wishListItemCollection as $item)
{
   // do things
}

在任何模板中,使用Magento 1.8,这一工程

Total: <?php echo $this->helper( wishlist )->getItemCount() ?>

// Items
$this->helper( wishlist )->getWishlist()->getItemCollection();
$wishList = Mage::getSingleton( wishlist/wishlist )->loadByCustomer($customer);
$wishListItemCollection = $wishList->getItemCollection();

foreach ($wishListItemCollection as $item)
{
    //do your thing e.g. echo $item->getName();
}

用所有细节,如姓名、图像等,进行这项工作。

<?php
 $customer = Mage::getSingleton( customer/session )->getCustomer();
 if($customer->getId())
{
     $wishlist = Mage::getModel( wishlist/wishlist )->loadByCustomer($customer, true);
     $wishListItemCollection = $wishlist->getItemCollection();
     foreach ($wishListItemCollection as $item)
     {
           echo $item->getName()."</br>";
           echo $item->getId()."</br>";
           echo $item->getPrice()."</br>";
           echo $item->getQty()."</br>";  
           $item = Mage::getModel( catalog/product )->setStoreId($item->getStoreId())->load($item->getProductId());
          if ($item->getId()) :
?>
<img src="<?php echo Mage::helper( catalog/image )->init($item,  small_image )->resize(113, 113); ?>" width="113" height="113" />
<?php endif; } } ?> 




相关问题
Magento addFieldToFilter allow NULLs

When using the Magento collection method addFieldToFilter is it possible to allow filtering by NULL values? I want to select all the products in a collection that have a custom attribute even if no ...

Get product link from Magento API

I am new to Magento and using their API. I need to be able to get the product url from the API call. I see that I can access the url_key and url_path, but unfortunately that s not necessarily what ...

magento extension installation

I want to install a Magento extension in WAMP, but not from the Magento connect system. How can I do this? I have the module (extension) code and I already installed the sample data in the Magento ...

Link to a specific step in onepage checkout

Is it possible to redirect the browser to nth step in the onepage checkout? If so, how would one go about doing it? I m working on a payment module and have a sort of "cancel" action that i would ...

How do I filter a collection by a YesNo type attribute?

I have a ‘featured’ attribute, which has a Yes/No select-list as the admin input. I presume that the values for Yes and No are 1 and 0, as they are for every other Yes/No list. However, if I try and ...

热门标签