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

时间:2016-07-21 15:25:44

标签: php magento

我正在使用第三方扩展程序在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>

1 个答案:

答案 0 :(得分:0)

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

一对多的关系就像

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

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

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

这是一个可以帮助您One-to-Many relationship in MySQL - how to build model?

的答案