Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swap seller name in product view page based on quantity

Tags:

magento

we have marketplace multi vendor/seller site.

we are displaying multiple sellers on product view page.

initially one Product is uploaded by seller "kidsdial4" , than same product is assigned by another seller "kidsdial6".

than in product view page, we are displaying both seller names like this

on top you can see seller kidsdial4

enter image description here

on bottom you can see seller kidsdial 6

enter image description here

here seller kidsdial4 have "zero" stock [out-of-stock ] for that product.

& kidsdial6 seller have quantity for that product.

so i want to display kidsdial 6 seller on top , kidsdial 4 should display on bottom.

<?php $productid=Mage::registry('current_product')->getId(); ?>
<?php if(count($this->sellerNewProductList())!=0 || count($this->sellerUsedProductList())!=0): ?>
    <div class="wk_mp_design" id="seller-list" style="clear:both">
        <div class="block block-account">
            <div class="head block-title">
                <strong>
                    <span class="wk_new_tab list_active_tab" for="seller-list-new"><?php echo $this->__('Sold By')." ".count($this->sellerNewProductList())."" ." Sellers "; ?></span>
                    <!-- <span class="wk_tab_seperator"></span>
                    <span class="wk_used_tab" for="seller-list-used"><?php echo $this->__('Used')." (".count($this->sellerUsedProductList()).")";?></span> -->
                </strong>
            </div>
            <div class="seller-list" id="seller-list-new">
                <?php if(count($this->sellerNewProductList())==0): ?>
                    <div class="fieldset wk_mp_fieldset">
                        <div class="wk_emptymsg">
                            <?php echo $this->__('No New Product Available') ?>
                        </div>
                    </div>
                <?php else: ?>
                    <div class="title">
                        <span class="lable profile"><?php echo $this->__('Sellers');?></span>
                        <span class="lable comment"><?php echo $this->__('Delivered By');?></span>
                        <span class="lable price"><?php echo $this->__('Price');?></span>
                        <span class="lable addto"><?php echo $this->__('');?></span>
                    </div>
                    <?php foreach($this->sellerNewProductList() as $seller): ?>
                        <?php
                            $userlist=Mage::getModel('marketplace/userprofile')->getCollection();
                            $userlist->addFieldToFilter('mageuserid',array('eq'=>$seller->getSellerId()));
                            foreach($userlist as $user){
                                $profileurl=$user->getProfileurl();
                                $logo=$user->getLogopic();
                            }
                        ?>

complete code of app/design/frontend/default/default/template/mpassignproduct/sellerlist.phtml => http://pasted.co/13849662

app/code/local/Webkul/Mpassignproduct/Block/Sellerlist.php

<?php

class Webkul_Mpassignproduct_Block_Sellerlist extends Mage_Core_Block_Template
{
    public function _prepareLayout() {
        return parent::_prepareLayout();
    }

    public function sellerNewProductList() {
        $productid=Mage::registry('current_product')->getId();
        $collection=Mage::getModel('mpassignproduct/mpassignproduct')->getCollection()
                        ->addFieldToFilter('product_id',array('eq'=>$productid))
                        ->addFieldToFilter('qty',array('gt'=>0))
                        ->addFieldToFilter('flag',array('eq'=>'1'))
                        ->addFieldToFilter('product_condition', array('eq'=>'new'));
        $collection->setOrder("price",ASC);
        return $collection;
    }

    public function sellerUsedProductList() {
        $productid=Mage::registry('current_product')->getId();
        $collection = Mage::getModel('mpassignproduct/mpassignproduct')->getCollection()
                        ->addFieldToFilter('product_id',array('eq'=>$productid))
                        ->addFieldToFilter('qty',array('gt'=>0))
                        ->addFieldToFilter('product_condition',array('eq'=>'used'))
                        ->addFieldToFilter('flag',array('eq'=>'1'));
        $collection->setOrder("price",ASC);
        return $collection;
    }
}
like image 727
fresher Avatar asked Apr 06 '16 10:04

fresher


1 Answers

Sort the collection sellerNewProductList() by quantity (highest to lowest) in your block

like image 88
hardayborlar Avatar answered Sep 29 '22 11:09

hardayborlar