1

We are using Marketplace in my website also some product have more then one seller. Even every seller have unique SKU

<?php $connectionresource = Mage::getSingleton('core/resource');
                $readconnection = $connectionresource->getConnection('core_read');
                $allrecord = $readconnection->select()->from(array('mpassignproduct'=>'marketplace_assignproduct'))->where('mpassignproduct.mpassignproduct_id=?', $res['mpassignproduct_id']);
                $mpassignproduct =$readconnection->fetchAll($allrecord);     
                if(count($mpassignproduct)) {
                 foreach($mpassignproduct as $assignproduct)
                   {   $name = $name."<p style='float:left;'><a href='".Mage::getUrl($products->getUrlPath())."' target='blank'>".$orderdproname."</a> <strong>".$assignproduct['sku']." </strong> <span>".intval($res['magequantity'])."</span>&nbsp;</p>";

                   }
                } else {
                     $name = $name."<p style='float:left;'><a href='".Mage::getUrl($products->getUrlPath())."' target='blank'>".$orderdproname."</a> <strong>".$products->getSku()." </strong> <span>".intval($res['magequantity'])."</span>&nbsp;</p>";
                      }


                    }

We used above code to Model/saleslist.php it's working find But in front end .phtml file i can't able to get unique sku? How to get that Sku in front end file?

vieworder.phtml






<table class="data-table" id="my-orders-table" summary="<?php echo $this->__('Items Ordered') ?>">
                    <col />
                    <col width="1" />
                    <col width="1" />
                    <col width="1" />
                    <col width="1" />
                    <thead>
                        <tr>
                            <th width="30%"><?php echo $this->__('Product Name') ?></th>
                            <th class="a-right"><?php echo $this->__('SKU') ?></th>
                             <th class="a-right"><?php echo $this->__('Price') ?></th>

                            <th class="a-right"><?php echo $this->__('Total Price') ?></th>
                            <th class="a-right"><?php echo $this->__('Admin Commission') ?></th>
                            <th class="a-right"><?php echo $this->__('Sub Total') ?></th>
                        </tr>
                    </thead>
                    <?php $_items = $_order->getItemsCollection(); ?>
                    <?php $i = 0; ?>
                    <?php $_count = $_items->count(); ?>
                    <?php 
                    $subtotal = 0;
                    $shippingamount = 0;
                    $itemPrice = 0;
                    foreach ($_items as $_item){
                        $row_total = 0;
                        $available_seller_item = 0;
                        $seller_item_cost = 0;          
                        $orderid = $this->getRequest()->getParam('id');
                        $vendor_item_status=$this->getItemStatus($orderid,$_item->getProductId());                      
                        $seller_orderslist=Mage::getModel('marketplace/saleslist')->getCollection()
                                                     ->addFieldToFilter('mageproownerid',array('eq'=>$customerid))
                                                     ->addFieldToFilter('mageorderid',array('eq'=>$orderid))
                                                     ->addFieldToFilter('mageproid',array('eq'=>$_item->getProductId()))
                                                     // ->addFieldToFilter('mageproprice',array('eq'=>$_item->getPrice()))
                                                     ->setOrder('mageorderid','DESC');
                        foreach($seller_orderslist as $seller_item){
                            $parentitem_falg = 0;
                            $available_seller_item = 1;
                            $seller_item_commission = $seller_item->getTotalcommision();
                            $shippingcharges = $seller_item->getShippingCharges();
                            $itemPrice = $seller_item->getMageproprice();
                        }
                        if($available_seller_item == 1){
                            $i++;
                            $seller_item_qty = $_item->getQtyOrdered();
                            $row_total=$itemPrice*$seller_item_qty;
                            $seller_item_cost = $row_total-$seller_item_commission;
                            $subtotal=$subtotal+$seller_item_cost;
                            $shippingamount = $shippingamount+$shippingcharges;

                            $result = array();
                            if ($options = $_item->getProductOptions()) {
                                if (isset($options['options'])) {
                                    $result = array_merge($result, $options['options']);
                                }
                                if (isset($options['additional_options'])) {
                                    $result = array_merge($result, $options['additional_options']);
                                }
                                if (isset($options['attributes_info'])) {
                                    $result = array_merge($result, $options['attributes_info']);
                                }
                            }
                            // for bundle product
                            $bundleitems = array_merge(array($_item), $_item->getChildrenItems());
                            $_count = count ($bundleitems);
                            $_index = 0;
                            $_prevOptionId = '';                            
                            ?>
                            <?php if ($_item->getParentItem()) continue; ?>
                            <tbody class="myorder">
                                <!-- <tbody class="<?php echo $class = ($i%2 != 0)? 'odd':'even'?>"> -->
                                <?php
                                if($_item->getProductType()!='bundle'){
                                ?>
                                    <?php if($labl!=''){$pname=$_item->getName() .'(' .$labl. ')';} else{$pname=$_item->getName();} ?>
                                    <tr class="border" id="order-item-row-<?php echo $_item->getMageproid() ?>">
                                        <td>
                                            <h3 class="product-name"><?php echo $pname;?></h3>

                                            <?php if($_options = $result): ?>
                                                <dl class="item-options">
                                                <?php foreach ($_options as $_option) : ?>
                                                    <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
                                                    <?php if (!$this->getPrintStatus()): ?>
                                                        <?php $_formatedOptionValue = $this->getFormatedOptionValue($_option) ?>
                                                        <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>>
                                                            <?php echo $_formatedOptionValue['value'] ?>
                                                            <?php if (isset($_formatedOptionValue['full_view'])): ?>
                                                            <div class="truncated_full_value">
                                                                <dl class="item-options">
                                                                    <dt><?php echo $this->escapeHtml($_option['label']) ?></dt>
                                                                    <dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
                                                                </dl>
                                                            </div>
                                                            <?php endif; ?>
                                                        </dd>
                                                    <?php else: ?>
                                                        <dd>
                                                            <?php echo nl2br($this->escapeHtml( (isset($_option['print_value']) ? $_option['print_value'] : $_option['value']) )) ?>
                                                        </dd>
                                                    <?php endif; ?>
                                                <?php endforeach; ?>
                                                </dl>
                                            <?php endif; ?>
                                        </td>
                                        <td class="sku">
                                            <?php echo $_item->getSku();?>

                                        </td>
                                        <td class="price"><?php echo Mage::helper('core')->currency($_item->getPrice(), true, false);?></td>

                                        <td class="price"><?php echo Mage::helper('core')->currency($row_total, true, false);?></td>
                                        <td class="price"><?php echo Mage::helper('core')->currency($seller_item_commission, true, false);?></td>
                                        <td class="row_total"><?php echo Mage::helper('core')->currency($seller_item_cost, true, false);?></td>
                                    </tr>
                                <?php
                                }else{
                                ?>
                                <?php foreach ($bundleitems as $_bundleitem): ?>
                                    <?php
                                    $attributes_option = null;
                                    if ($_bundleitem instanceof Mage_Sales_Model_Order_Item) {
                                        $options = $_bundleitem->getProductOptions();
                                    } else {
                                        $options = $_bundleitem->getOrderItem()->getProductOptions();
                                    }
                                    if (isset($options['bundle_selection_attributes'])) {
                                        $attributes_option =  unserialize($options['bundle_selection_attributes']);
                                    }
                                    ?>

                                    <?php if ($_bundleitem->getParentItem()): ?>
                                        <?php $attributes = $attributes_option ?>
                                        <?php if ($_prevOptionId != $attributes['option_id']): ?>
                                        <tr<?php if ($_bundleitem->getLastRow()) echo 'class="last"'; ?>>
                                            <td><div class="option-label"><?php echo $attributes['option_label'] ?></div></td>
                                            <td>&nbsp;</td>
                                            <td>&nbsp;</td>
                                            <td>&nbsp;</td>
                                            <td>&nbsp;</td>
                                            <td>&nbsp;</td>
                                        </tr>
                                        <?php $_prevOptionId = $attributes['option_id'] ?>
                                        <?php endif; ?>
                                    <?php endif; ?>
                                    <tr<?php echo (++$_index==$_count)?' class="border"':'' ?> id="order-item-row-<?php echo $_bundleitem->getId() ?>">
                                        <?php 
                                        if (!$_bundleitem->getParentItem()){?>
                                            <td><h3 class="product-name"><?php echo $this->escapeHtml($_bundleitem->getName()) ?></h3></td>
                                            <td class="price"><?php echo Mage::helper('core')->currency($_item->getPrice(), true, false);?></td>
                                            <td>&nbsp;</td>
                                            <td class="price"><?php echo Mage::helper('core')->currency($row_total, true, false);?></td>
                                            <td class="price"><?php echo Mage::helper('core')->currency($seller_item_commission, true, false);?></td>
                                            <td class="row_total"><?php echo Mage::helper('core')->currency($seller_item_cost, true, false);?></td>
                                        <?php
                                        } else{
                                            $_bundleitem_child_name ='';
                                            if ($attributes = $attributes_option){
                                                $_bundleitem_child_name =  sprintf('%d', $attributes['qty']) . ' x ' .$this->escapeHtml($_bundleitem->getName()) . " " . Mage::helper('core')->currency($attributes['price'], true, false);
                                            } else {
                                                $_bundleitem_child_name = $this->escapeHtml($_bundleitem->getName());
                                            }
                                            ?>
                                            <td><div class="option-value"><?php echo $_bundleitem_child_name?></div></td>
                                            <td>&nbsp;</td>
                                            <td class="item_status">
                                                <span class="nobr">
                                                    <?php if ($_item->getQtyOrdered() > 0): ?>
                                                        <?php echo $this->__('Ordered'); ?>: <strong><?php echo $_item->getQtyOrdered()*1 ?></strong><br />
                                                    <?php endif; ?>
                                                    <?php if ($_item->getQtyShipped() > 0): ?>
                                                        <?php echo $this->__('Shipped'); ?>: <strong><?php echo $_item->getQtyShipped()*1 ?></strong><br />
                                                    <?php endif; ?>
                                                    <?php if ($_item->getQtyCanceled() > 0): ?>
                                                        <?php echo $this->__('Canceled'); ?>: <strong><?php echo $_item->getQtyCanceled()*1 ?></strong><br />
                                                    <?php endif; ?>
                                                    <?php if ($_item->getQtyRefunded() > 0): ?>
                                                        <?php echo $this->__('Refunded'); ?>: <strong><?php echo $_item->getQtyRefunded()*1 ?></strong><br />
                                                    <?php endif; ?>
                                                </span>
                                            </td>
                                            <td>&nbsp;</td>
                                            <td>&nbsp;</td>
                                            <td>&nbsp;</td>
                                        <?php
                                        }?>
                                    </tr>
                                <?php endforeach; ?>
                                <?php
                                }?>
                            <!-- </tbody> -->
                        </tbody>
                            <?php 
                        }
                    }?>
  • is this seller login page? can you add more code like which collection you trying to get this mean in order item or seller product or else? – Qaisar Satti Jan 11 '16 at 12:09
  • i tried your code it's not working is there any solution – Magento 2 Jan 11 '16 at 12:18
  • add the answer passing the seller id and product id – Qaisar Satti Jan 11 '16 at 12:23
  • @Kothari : You are going wrong way. This module are provided default functionality are you need. – Abdul Jan 11 '16 at 12:29
  • @Abdul it's not a default functionality we customize based on Qaisar Satti – Magento 2 Jan 11 '16 at 12:31
1

just pass the product id to where

$customerid=Mage::getSingleton('customer/session')->getCustomerId();

<?php $connectionresource = Mage::getSingleton('core/resource');
                $readconnection = $connectionresource->getConnection('core_read');
                $allrecord = $readconnection->select()->from(array('mpassignproduct'=>'marketplace_assignproduct'))->where('mpassignproduct.product_id=?', $item->getProductId())->where('mpassignproduct.seller_id_id=?', $customerid);
                $mpassignproduct =$readconnection->fetchAll($allrecord);     
                if(count($mpassignproduct)) {
                 foreach($mpassignproduct as $assignproduct)
                   {   echo $assignproduct['sku']; 

                   }
                } 
| improve this answer | |
  • Where to pass product id – Magento 2 Jan 11 '16 at 12:35
  • $res['product_id'] here add your product id – Qaisar Satti Jan 11 '16 at 12:35
  • i think this code not availble in above – Magento 2 Jan 11 '16 at 12:39
  • no this is new code for getting product from seller id and product id – Qaisar Satti Jan 11 '16 at 12:42
  • 1
    $_item this is the problem i got it. it's working thanks – Magento 2 Jan 12 '16 at 5: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.