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 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

Array ( [entity_id] => 1800 [state] => invoice [status] => invoice [coupon_code] => [protect_code] => 1e81cb [shipping_description] => Shipping - Charges : [is_virtual] => 0 [store_id] => 1 [customer_id] => 262 [base_discount_amount] => 0.0000 [base_discount_canceled] => [base_discount_invoiced] => 0.0000 [base_discount_refunded] => [base_grand_total] => 200.0000 [base_shipping_amount] => 0.0000 [base_shipping_canceled] => [base_shipping_invoiced] => 0.0000 [base_shipping_refunded] => [base_shipping_tax_amount] => 0.0000 [base_shipping_tax_refunded] => [base_subtotal] => 200.0000 [base_subtotal_canceled] => [base_subtotal_invoiced] => 0.0000 [base_subtotal_refunded] => [base_tax_amount] => 0.0000 [base_tax_canceled] => [base_tax_invoiced] => 0.0000 [base_tax_refunded] => [base_to_global_rate] => 1.0000 [base_to_order_rate] => 1.0000 [base_total_canceled] => [base_total_invoiced] => 200.0000 [base_total_invoiced_cost] => 0.0000 [base_total_offline_refunded] => [base_total_online_refunded] => [base_total_paid] => 200.0000 [base_total_qty_ordered] => [base_total_refunded] => [discount_amount] => 0.0000 [discount_canceled] => [discount_invoiced] => 0.0000 [discount_refunded] => [grand_total] => 200.0000 [shipping_amount] => 0.0000 [shipping_canceled] => [shipping_invoiced] => 0.0000 [shipping_refunded] => [shipping_tax_amount] => 0.0000 [shipping_tax_refunded] => [store_to_base_rate] => 1.0000 [store_to_order_rate] => 1.0000 [subtotal] => 200.0000 [subtotal_canceled] => [subtotal_invoiced] => 200.0000 [subtotal_refunded] => [tax_amount] => 0.0000 [tax_canceled] => [tax_invoiced] => 0.0000 [tax_refunded] => [total_canceled] => [total_invoiced] => 200.0000 [total_offline_refunded] => [total_online_refunded] => [total_paid] => 200.0000 [total_qty_ordered] => 1.0000 [total_refunded] => [can_ship_partially] => [can_ship_partially_item] => [customer_is_guest] => 0 [customer_note_notify] => 1 [billing_address_id] => 3599 [customer_group_id] => 1 [edit_increment] => [email_sent] => 1 [forced_shipment_with_invoice] => [gift_message_id] => [payment_auth_expiration] => [paypal_ipn_customer_notified] => [quote_address_id] => [quote_id] => 6948 [shipping_address_id] => 3600 [adjustment_negative] => [adjustment_positive] => [base_adjustment_negative] => [base_adjustment_positive] => [base_shipping_discount_amount] => 0.0000 [base_subtotal_incl_tax] => 200.0000 [base_total_due] => 0.0000 [payment_authorization_amount] => [shipping_discount_amount] => 0.0000 [subtotal_incl_tax] => 200.0000 [total_due] => 0.0000 [weight] => 1.0000 [customer_dob] => [increment_id] => 100001841 [applied_rule_ids] => [base_currency_code] => INR [customer_email] => besttoyskids@gmail.com [customer_firstname] => kids [customer_lastname] => d [customer_middlename] => [customer_prefix] => [customer_suffix] => [customer_taxvat] => [discount_description] => [ext_customer_id] => [ext_order_id] => [global_currency_code] => INR [hold_before_state] => [hold_before_status] => [order_currency_code] => INR [original_increment_id] => [relation_child_id] => [relation_child_real_id] => [relation_parent_id] => [relation_parent_real_id] => [remote_ip] => 27.34.240.114 [shipping_method] => mpperproductshipping_mpperproductshipping [store_currency_code] => INR [store_name] => Main Website Default Wide English [x_forwarded_for] => [customer_note] => [created_at] => 2016-01-11 11:12:42 [updated_at] => 2016-01-11 12:28:01 [total_item_count] => 1 [customer_gender] => [base_custbalance_amount] => [currency_base_id] => [currency_code] => [currency_rate] => [custbalance_amount] => [is_hold] => [is_multi_payment] => [real_order_id] => [tax_percent] => [tracking_numbers] => [hidden_tax_amount] => 0.0000 [base_hidden_tax_amount] => 0.0000 [shipping_hidden_tax_amount] => 0.0000 [base_shipping_hidden_tax_amnt] => 0.0000 [hidden_tax_invoiced] => 0.0000 [base_hidden_tax_invoiced] => 0.0000 [hidden_tax_refunded] => [base_hidden_tax_refunded] => [shipping_incl_tax] => 0.0000 [base_shipping_incl_tax] => 0.0000 [coupon_rule_name] => [mpcashondelivery] => 0.0000 [payment_authorization_expiration] => [forced_do_shipment_with_invoice] => [base_shipping_hidden_tax_amount] => 0.0000 )

  • have you added above code in phtml file? – Abdul Jan 11 '16 at 11:56
  • Ya but it's not working – Magento 2 Jan 11 '16 at 11:58
  • then need to add this code in order pdf model file – Abdul Jan 11 '16 at 12:06
  • @Abdul How to add is it work? – Magento 2 Jan 11 '16 at 17:12
1

copy this

app/code/core/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php

to

app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php

add your sku at line 54. add your code here..

    $_collection = Mage::getModel('marketplace/saleslist')->getCollection();
    $_collection->addFieldToFilter('mageorderid',$order->getEntityId()); 

    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'];
   }



  }else {
 $sku=$this->getSku($item);
    }
$lines[0][] = array(
            'text'  => Mage::helper('core/string')->str_split($sku, 17),
            'feed'  => 290,
            'align' => 'right'
        );
  • it showing Base sku only not seller sku – Magento 2 Jan 11 '16 at 12:29
  • add here your sku. you have orderid add your collection and get that. – Qaisar Satti Jan 11 '16 at 12:31
  • How to add here – Magento 2 Jan 11 '16 at 12:32
  • updated the answer check and feedback.. – Qaisar Satti Jan 11 '16 at 12:49
  • it shows error Call to a member function getId() on a non-object – Magento 2 Jan 11 '16 at 12:55

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.