we have marketplace multi vendor/seller site.
In our site lot of sellers have same Products, so in Product view page we display all sellers.
assume a Product is uploaded by seller "kidsdial4" , than same product is assigned by another seller "kidsdial6".
so in product view page, we are displaying both seller names like this
on top you can see seller kidsdial4 with Price Rs .20:
on bottom you can see seller kidsdial 6 with Price Rs .10:
here `seller kidsdial4 have Price Rs 20 for that product.
& kidsdial6 seller have have Price Rs.10 for that product.
so i want to display seller on top who is selling for lowest price
here, kidsdial 6 should display on top , kidsdial 4 should display on bottom.
we are trying below script in view.phtml , now in both above & below , Kidsdial6 seller name and his price displaying
.
but i want to display Kidsdial4 seller name & his price
in below.
jQuery(function($) {
function getPriceFromString(str){
return str.replace( /^\D+/g, '')
}
productPriceFormated = jQuery('#product_addtocart_form span.price').text();
productPrice = getPriceFromString(productPriceFormated);
lowestPrice = productPrice;
productId = 0;
soldBy = ''
jQuery('#seller-list-new form').each(function(index){
price = getPriceFromString(jQuery(this).find('span span.price').text());
if(price < lowestPrice){
lowestPrice = price;
productId = jQuery(this).find('.mpassignproduct_id').val()
soldBy = jQuery(this).find('div.wk_seller_profile').html()
}
});
if(productId > 0){
jQuery('#product_addtocart_form span.price').text(productPriceFormated.replace(productPrice, lowestPrice));
jQuery('input:hidden[name=product]').remove();
jQuery('#product_addtocart_form').prepend('<input type="hidden" value="' + productId + '" name="mpassignproduct_id" class="mpassignproduct_id">');
jQuery('#product_addtocart_form .soled-by-dealer span').html(soldBy)
}
});
complete code of app/design/frontend/default/default/template/mpassignproduct/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….
Best Answer
your price is not sorting try
$collection->getSelect()->setOrder()
for checking it is sorting try to run query
echo $collection->getSelect();