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> </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> </p>";
}
}
We used above code to Model/saleslist.php
it's working fine but in PDF Invoice it's showing Base Sku how to get seller SKU
default.php
class Mage_Sales_Model_Order_Pdf_Items_Invoice_Default extends Mage_Sales_Model_Order_Pdf_Items_Abstract
{
/**
* Draw item line
*/
public function draw()
{
$order = $this->getOrder();
$item = $this->getItem();
$pdf = $this->getPdf();
$page = $this->getPage();
$lines = array();
$_collection = Mage::getModel('marketplace/saleslist')->getCollection();
$_collection->addFieldToFilter('mageorderid',$order->getOrderId());
foreach($_collection as $res){
$connectionresource = Mage::getSingleton('core/resource');
$readconnection = $connectionresource->getConnection('core_read');
$allrecord = $readconnection->select()->from(array('mpassignproduct'=>'marketplace_assignproduct'))->where('mpassignproduct.mpassignproduct_id_id=?', $res->getMpassignproductId());
$mpassignproduct =$readconnection->fetchAll($allrecord);
if(count($mpassignproduct)) {
foreach($mpassignproduct as $assignproduct)
{
$sku=$assignproduct['sku'];
}
}
print_r($res);
exit;
}
// draw Product name
$lines[0] = array(array(
'text' => Mage::helper('core/string')->str_split($item->getName(), 35, true, true),
'feed' => 35,
));
// draw SKU
$lines[0][] = array(
'text' => Mage::helper('core/string')->str_split($this->getSku($item), 17),
'feed' => 290,
'align' => 'right'
);
// draw QTY
$lines[0][] = array(
'text' => $item->getQty() * 1,
'feed' => 435,
'align' => 'right'
);
// draw item Prices
$i = 0;
$prices = $this->getItemPricesForDisplay();
$feedPrice = 395;
$feedSubtotal = $feedPrice + 170;
foreach ($prices as $priceData){
if (isset($priceData['label'])) {
// draw Price label
$lines[$i][] = array(
'text' => $priceData['label'],
'feed' => $feedPrice,
'align' => 'right'
);
// draw Subtotal label
$lines[$i][] = array(
'text' => $priceData['label'],
'feed' => $feedSubtotal,
'align' => 'right'
);
$i++;
}
// draw Price
$lines[$i][] = array(
'text' => $priceData['price'],
'feed' => $feedPrice,
'font' => 'bold',
'align' => 'right'
);
// draw Subtotal
$lines[$i][] = array(
'text' => $priceData['subtotal'],
'feed' => $feedSubtotal,
'font' => 'bold',
'align' => 'right'
);
$i++;
}
// draw Tax
$lines[0][] = array(
'text' => $order->formatPriceTxt($item->getTaxAmount()),
'feed' => 495,
'font' => 'bold',
'align' => 'right'
);
// custom options
$options = $this->getItemOptions();
if ($options) {
foreach ($options as $option) {
// draw options label
$lines[][] = array(
'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 40, true, true),
'font' => 'italic',
'feed' => 35
);
if ($option['value']) {
if (isset($option['print_value'])) {
$_printValue = $option['print_value'];
} else {
$_printValue = strip_tags($option['value']);
}
$values = explode(', ', $_printValue);
foreach ($values as $value) {
$lines[][] = array(
'text' => Mage::helper('core/string')->str_split($value, 30, true, true),
'feed' => 40
);
}
}
}
}
$lineBlock = array(
'lines' => $lines,
'height' => 20
);
$page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
$this->setPage($page);
}
}
Output