1

您好正在自定义 magento 愿望清单,我想在愿望清单上的每个产品上显示图像。目前产品显示默认图像(无图像)。在我的愿望清单目录中的 view.phtml 中,这是我的代码

foreach($this->getWishlist() as $item){
     // ... some code

     <img src="<?php echo $this->helper('catalog/image')->init($item, 'small_image')->resize(113, 113)*/?>" alt="<?php echo $item->getName();?>" width="113"/>
     // the image that always shows the no image, it does not display the product image..
     // I think there is something wrong with  $this->helper('catalog/image')->init($item, 'small_image')->resize(113, 113)

     // i try to print thr $item
     print_r($item);

}

这是结果

Mage_Wishlist_Model_Item Object
(
    [_customOptionDownloadUrl:protected] => wishlist/index/downloadCustomOption
    [_eventPrefix:protected] => wishlist_item
    [_eventObject:protected] => item
    [_options:protected] => Array
        (
            [0] => Mage_Wishlist_Model_Item_Option Object
                (
                    [_item:protected] => Mage_Wishlist_Model_Item Object
 *RECURSION*
                    [_product:protected] => 
                    [_eventPrefix:protected] => core_abstract
                    [_eventObject:protected] => object
                    [_resourceName:protected] => wishlist/item_option
                    [_resource:protected] => 
                    [_resourceCollectionName:protected] => wishlist/item_option_collection
                    [_cacheTag:protected] => 
                    [_dataSaveAllowed:protected] => 1
                    [_isObjectNew:protected] => 
                    [_data:protected] => Array
                        (
                            [option_id] => 26
                            [wishlist_item_id] => 26
                            [product_id] => 6767
                            [code] => info_buyRequest
                            [value] => a:1:{s:7:"product";s:4:"6767";}
                        )

                    [_hasDataChanges:protected] => 1
                    [_origData:protected] => Array
                        (
                            [option_id] => 26
                            [wishlist_item_id] => 26
                            [product_id] => 6767
                            [code] => info_buyRequest
                            [value] => a:1:{s:7:"product";s:4:"6767";}
                        )

                    [_idFieldName:protected] => option_id
                    [_isDeleted:protected] => 
                    [_oldFieldsMap:protected] => Array
                        (
                        )

                    [_syncFieldsMap:protected] => Array
                        (
                        )

                )

        )

    [_optionsByCode:protected] => Array
        (
            [info_buyRequest] => Mage_Wishlist_Model_Item_Option Object
                (
                    [_item:protected] => Mage_Wishlist_Model_Item Object
 *RECURSION*
                    [_product:protected] => 
                    [_eventPrefix:protected] => core_abstract
                    [_eventObject:protected] => object
                    [_resourceName:protected] => wishlist/item_option
                    [_resource:protected] => 
                    [_resourceCollectionName:protected] => wishlist/item_option_collection
                    [_cacheTag:protected] => 
                    [_dataSaveAllowed:protected] => 1
                    [_isObjectNew:protected] => 
                    [_data:protected] => Array
                        (
                            [option_id] => 26
                            [wishlist_item_id] => 26
                            [product_id] => 6767
                            [code] => info_buyRequest
                            [value] => a:1:{s:7:"product";s:4:"6767";}
                        )

                    [_hasDataChanges:protected] => 1
                    [_origData:protected] => Array
                        (
                            [option_id] => 26
                            [wishlist_item_id] => 26
                            [product_id] => 6767
                            [code] => info_buyRequest
                            [value] => a:1:{s:7:"product";s:4:"6767";}
                        )

                    [_idFieldName:protected] => option_id
                    [_isDeleted:protected] => 
                    [_oldFieldsMap:protected] => Array
                        (
                        )

                    [_syncFieldsMap:protected] => Array
                        (
                        )

                )

        )

    [_notRepresentOptions:protected] => Array
        (
            [0] => info_buyRequest
        )

    [_flagOptionsSaved:protected] => 
    [_resourceName:protected] => wishlist/item
    [_resource:protected] => 
    [_resourceCollectionName:protected] => wishlist/item_collection
    [_cacheTag:protected] => 
    [_dataSaveAllowed:protected] => 1
    [_isObjectNew:protected] => 
    [_data:protected] => Array
        (
            [wishlist_item_id] => 26
            [wishlist_id] => 5
            [product_id] => 6767
            [store_id] => 1
            [added_at] => 2013-06-11 03:14:04
            [description] => 
            [qty] => 1.0000
            [product] => Mage_Catalog_Model_Product Object
                (
                    [_cacheTag:protected] => catalog_product
                    [_eventPrefix:protected] => catalog_product
                    [_eventObject:protected] => product
                    [_canAffectOptions:protected] => 
                    [_typeInstance:protected] => 
                    [_typeInstanceSingleton:protected] => 
                    [_linkInstance:protected] => 
                    [_customOptions:protected] => Array
                        (
                        )

                    [_urlModel:protected] => 
                    [_errors:protected] => Array
                        (
                        )

                    [_optionInstance:protected] => 
                    [_options:protected] => Array
                        (
                        )

                    [_reservedAttributes:protected] => 
                    [_isDuplicable:protected] => 1
                    [_calculatePrice:protected] => 1
                    [_defaultValues:protected] => Array
                        (
                        )

                    [_storeValuesFlags:protected] => Array
                        (
                        )

                    [_lockedAttributes:protected] => Array
                        (
                        )

                    [_isDeleteable:protected] => 1
                    [_isReadonly:protected] => 
                    [_resourceName:protected] => catalog/product
                    [_resource:protected] => 
                    [_resourceCollectionName:protected] => catalog/product_collection
                    [_dataSaveAllowed:protected] => 1
                    [_isObjectNew:protected] => 
                    [_data:protected] => Array
                        (
                            [entity_id] => 6767
                            [entity_type_id] => 4
                            [attribute_set_id] => 4
                            [type_id] => simple
                            [sku] => sku6768
                            [has_options] => 0
                            [required_options] => 0
                            [created_at] => 2011-07-25 19:46:25
                            [updated_at] => 2013-06-03 21:08:50
                            [cat_index_position] => 80000
                            [price] => 0.0000
                            [tax_class_id] => 2
                            [final_price] => 0.0000
                            [minimal_price] => 0.0000
                            [min_price] => 0.0000
                            [max_price] => 0.0000
                            [tier_price] => 
                            [image_label] => Amplifier +15V Input
                            [manufacturer2] => 130
                            [name] => Amplifier +15V Input
                            [small_image] => /d/s/dsc00394.jpg
                            [small_image_label] => Amplifier +15V Input
                            [thumbnail] => /d/s/dsc00394.jpg
                            [thumbnail_label] => Amplifier +15V Input
                            [url_key] => amplifier-15v-input
                            [url_path] => amplifier-15v-input.html
                            [short_description] => <p>&#160;</p>
                            [status] => 1
                            [visibility] => 4
                            [is_salable] => 1
                            [stock_item] => Varien_Object Object
                                (
                                    [_data:protected] => Array
                                        (
                                            [is_in_stock] => 1
                                        )

                                    [_hasDataChanges:protected] => 
                                    [_origData:protected] => 
                                    [_idFieldName:protected] => 
                                    [_isDeleted:protected] => 
                                    [_oldFieldsMap:protected] => Array
                                        (
                                        )

                                    [_syncFieldsMap:protected] => Array
                                        (
                                        )

                                )

                            [request_path] => amplifier-15v-input.html
                        )

                    [_hasDataChanges:protected] => 1
                    [_origData:protected] => 
                    [_idFieldName:protected] => entity_id
                    [_isDeleted:protected] => 
                    [_oldFieldsMap:protected] => Array
                        (
                        )

                    [_syncFieldsMap:protected] => Array
                        (
                        )

                )

            [product_name] => Amplifier +15V Input
            [name] => Amplifier +15V Input
            [price] => 0.0000
        )

    [_hasDataChanges:protected] => 
    [_origData:protected] => Array
        (
            [wishlist_item_id] => 26
            [wishlist_id] => 5
            [product_id] => 6767
            [store_id] => 1
            [added_at] => 2013-06-11 03:14:04
            [description] => 
            [qty] => 1.0000
        )

    [_idFieldName:protected] => wishlist_item_id
    [_isDeleted:protected] => 
    [_oldFieldsMap:protected] => Array
        (
        )

    [_syncFieldsMap:protected] => Array
        (
        )

)

[_resourceName:protected] => catalog/product现在,我的问题是如何[small_image] => /d/s/dsc00394.jpgprint_r($item);?

我只想将它打印在我的图像源上,有人知道我的情况吗?提前致谢 ....

4

1 回答 1

1

我得到了解决方案,我试试这个。

foreach ($item->_data as $item_img){
        echo $item_img->_data[small_image];
    }
于 2013-06-11T07:30:13.307 回答