5

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.

sellerlist.phtml

<?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 sellerlist.phtml` => http://pasted.co/13849662

wk_block.phtml

<?php
    $helper=Mage::helper('marketplace');
    $_product=Mage::registry('current_product');
    $productowner=Mage::getModel('marketplace/product')->isCustomerProduct($_product['entity_id']);
    if($productowner['userid']!=""){
        $captchenable = $percent = Mage::getStoreConfig('marketplace/marketplace_options/captcha');
        $rowsocial=Mage::getModel('marketplace/userprofile')->getPartnerProfileById($productowner['userid']);
?>

<div class="block wk-block block-viewed">
    <div class="block-title"><strong><span>
    <?php   if($rowsocial['shoptitle']!='')
            echo $rowsocial['shoptitle'];
        else
            echo  $rowsocial['profileurl']; ?>
    </span></strong></div>
    <div class="block-content">
        <div class="wk_blockdetail">   
            <ul class="partnerlinks">
                <li>
                    <a href="<?php echo  Mage::getUrl('marketplace/seller/collection').$rowsocial['profileurl'] ?>" title="<?php echo $helper->__('Visit Complete Collection') ?>" id="siteconnect"><?php echo $helper->__('View Collection') ?></a>
                </li>
                <li class="profile-view">
                    <a href="<?php echo  Mage::getUrl()."marketplace/seller/profile/".$rowsocial['profileurl'] ?>" title="<?php echo $helper->__('Visit Profile') ?>" id="profileconnect"><?php echo $helper->__('View Profile') ?></a>
                    <div class="wk-block-hover-div">
                        <div class="arrow"></div>
                        <?php echo $rowsocial['compdesi']; ?>
                    </div>
                </li>

                <?php echo $this->getChildHtml();?>

            </ul>
        </div>
    </div> 
</div>

full code of wk_block.phtml : http://pasted.co/0a221176

Sellerlist.php

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

<?php

class Exam_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;
    }
}

i will give extra 100 bounty points if i get answer....

1
+100

i already answer there so the same question

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->getSelect()->order("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->getSelect()->order("price",ASC);
    return $collection;
}

for checking it is sorting try to run query echo $collection->getSelect();

2
+50

You can order the position of seller in your collection by modifying your both the seller collection like below.

As you have already filtered the Seller list by quantity having more than 0 value.

By ordering Price and Qty both you will get seller having less price at first place and if both the seller having same price then it will consider seller having more number of qty for that particular product as first place.

You can apply these to both your 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); your order by commented
          $collection->getSelect()->order("price ASC")->order("qty DESC");
    return $collection;
}

Let me know if you still have any problem.

  • i tried your code for sellerUsedProductList() function , now in link its displaying this result : SOLD BY 1 SELLERS our products are new products, so i tried same way for function sellerNewProductList() , but i got this error : Fatal error: Call to a member function order() on a non-object in : $collection->getSelect->order("price ASC, qty DESC"); – Baby in Magento Apr 15 '16 at 7:02
  • Oops !! There is a type You can try $collection->getSelect()->order("price ASC , qty Desc"); – Codrain Technolabs Pvt Ltd Apr 15 '16 at 7:08
  • pleease check link – Baby in Magento Apr 15 '16 at 7:13
  • price is a field name from your seller table. Replace price and qty from the seller table field name for eg if you are using seller_price field name in your Seller Product table. then replace price with seller_price same for qty – Codrain Technolabs Pvt Ltd Apr 15 '16 at 7:18
  • when i use only price or qty as like $collection->getSelect()->order("price ASC"); or $collection->getSelect()->order("qty Desc"); , i dont get this error , but when i use both than only error. & i checked in related table , it showing like this : prnt.sc/asglzm or did i checked in wrong table ? – Baby in Magento Apr 15 '16 at 7:29
1

I couldn't do the code but the idea is very simple. Before all, load all the sellers that have this product, create an array with the "name"=>"stock" , order the array with the hight value of the "stock" at first, and then loop around the array, loading the seller by the name, and using his stock to show it.

  • Thanks for nice idea, i will try & let you know how it goes, if possible please provide me the code, so that its going to be very helpfull for me. – Baby in Magento Apr 11 '16 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.