在“产品”页面中为“客户”图像添加图像上传器


Add Image uploader in Product page for Customers images to product

实际上,我已经完成了一项任务,我想在产品页面的前端提供图像上传选项,供注册客户为产品添加自己的图像,并且应该只有他们才能看到。但这应该通过触摸magento中的核心部分来完成。我甚至不知道该怎么做任何人都请帮忙。提前谢谢。。

您可以尝试以下步骤:
1.添加产品的自定义文件属性(是否必填应为
2.在前端视图的产品选项div下的dl上添加一个用于识别文件类型选项的类。您可以为此使用jQuery,但不要忘记包含jQuery
3.你需要检查登录的客户(view.ppthml)。试试下面的代码

<script>
    jQuery(document).ready(function(){
        jQuery(".product-options dl dt").each(function(){
          if(jQuery(this).next().find("input").attr("type") == 'file'){
            jQuery(this).next().addClass('file-field');
          }
        });
    }); 
</script>
<?php if (Mage::getSingleton('customer/session')->isLoggedIn()) : ?> 
    <style>
        .file-field{visibility: visible;}
    </style>
<?php else: ?>
    <style>
        .file-field{visibility: hidden;}
    </style>
<?php endif; ?>