【问题标题】:How can i display seller's products on seller profile page?如何在卖家资料页面上显示卖家的产品?
【发布时间】:2016-07-24 10:18:03
【问题描述】:

我正在使用第三方扩展程序在 magento 上构建一个多卖家市场,该扩展程序显示卖家的个人资料页面、详细信息和评论,但不显示卖家的产品。

如何在卖家资料页面上显示卖家的产品?

这是卖家profile.phtml代码:

<?php
$seller = $this->sellerProfile();
$country = Mage::getModel('directory/country')->loadByCode($seller['country']);
?>

<div class="seller-profile">
<div class="seller-top-panel">
    <ul>
        <li>
            <div class="seller-profile-image">
                <img src="<?php echo Mage::helper('marketplace')->getImagePath($seller['image']); ?>" height="140"     width="140">
            </div>
        </li>
        <li class="shop-info">
            <div class="shopname">
                <h2><?php echo $seller['shop_name']; ?></h2>
            </div>
            <div class="shop-description">
                <p><?php echo $seller['shop_description']; ?></p>
            </div>
            <div class="shop-contact">
                <span><?php echo $this->__('<b>Phone</b>: %s',$seller['telephone']);?></span>
            </div>
            <div class="seller-profile-contact">
                <span><?php echo $this->__('<b>Email</b>: %s',$seller['email']); ?></span>
            </div>
            <div class="shop-location">
                <span><?php echo $this->__('<b>Country</b>: %s',$country->getName());?></span>
            </div>
            </li>

        <li class="summary-overview">
            <h3><?php echo $this->__('Rating Conclusion') ?></h3>
            <?php foreach($this->ratingOverview() as $rate):?>
                <div class="rating-list">
                    <?php $ratingName =  $this->getRatingName($rate['rating_id']); ?>
                    <?php $avgPercentage = ($rate['sub_total']*100)/($rate['rating_count']*5); ?>
                    <?php $rating = $rate['sub_total']/$rate['rating_count'] ; ?>
                    <?php $ratingTitle = $this->__("Rating: ").round($rating,1)."of 5"; ?>
                    <div class="rating-stars">
                        <div class="blank-stars"></div>
                        <div title="<?php echo $ratingTitle; ?>"class="fill-stars" style="width:<?php echo round    ($avgPercentage,2); ?>%"></div>
                    </div>
                    <div class="rating-name"><?php echo $ratingName; ?></div>
                </div>
        <?php endforeach; ?>        
        </li>
        <li>
            <?php $sum = 0;foreach($this->getReviewStars() as $rate) $sum += $rate['value_count'];?>
            <?php $positive = array(5,4); $rate = $this->getPositivePercentage($positive);?> 
            <div class="rating-linegraph">
                <div class="avgRatingSection sellerrating">
                    <?php $positiveTotal = count($rate) == 0 ? 0 : ($rate['positive_total']/$sum)*100 ?>
                    <div class="rating-percentage">
                        <span class="positive-average"><?php echo round($positiveTotal)."%"; ?></span> 
                        <span class="positve-label"><?php echo $this->__('Positive') ?></span>
                        </div> 
                        <span><?php echo $this->__('Based on %d ratings',$sum) ?></span>
                    </div>
                <div class="seller-rating-bar seller-rating">
                    <ul>
                    <?php $count=5;for($count=5;$count>=1;$count--):
                        $rate =  $this->getReviewStar($count);

                        $avg = ($rate == null ? 0 : (($rate['value_count']/$sum)*100));
                        ?>
                        <li>
                            <span><?php echo $count.$this->__('star') ?> </span>
                            <div class="blank-ratingbar">
                                <div class="fill-bar" style="width:<?php echo $avg;  ?>%"></div>
                            </div>
                            <span class="rate-vote"><?php echo $rate == NULL ? 0 : $rate['value_count']; ?    ></span>
                        </li>
                <?php endfor; ?>

                    </ul>
                </div>
                <div class="seller-rate-type seller-rating">
                    <div class="border type-positive"><?php echo $this->__('Positive'); ?></div>
                    <div class="border type-neutral"><?php echo $this->__('Neutral');?></div>
                    <div class="border type-negative"><?php echo $this->__('Negative') ;?></div>
                </div>
            </div>
        </li>
</div>
</div>

【问题讨论】:

  • 欢迎来到 Stack Overflow!我尽可能地编辑了你的问题。但是,添加描述,以便更多了解该主题的人看到它。请在您遇到的特定错误消息中进行编辑,以防有必要识别特定问题。祝你好运!

标签: php magento


【解决方案1】:

如果卖家的产品与其他产品不同,那么您可以使用一对多关系

一对多的关系就像

每个卖家可能有零个、一个或多个产品。但是一个产品只能属于一个卖家

例如 你有一个叫杰克的卖家,他在产品表上有 4 个产品 您将使用卖家表上的杰克 id 创建一个链接到表产品的外键

注意:如果您从卖家表中删除 jack,他的所有产品也将被删除,这是有道理的,您不能向商家提供他的卖家不存在的产品

这是一个可以帮助你的答案One-to-Many relationship in MySQL - how to build model?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-04
    • 1970-01-01
    • 1970-01-01
    • 2022-10-07
    • 1970-01-01
    相关资源
    最近更新 更多