2

Friends,

i have read a lot about this part. Lots of people want to have some custom attributes in the PDF invoices and on the adminHtml part.

I am not able to get it work on the PDF. it works on the Cart, Checkout, adminHtml but not on the pdf.

I modify (rewrite): app/code/local/Mage/Sales/Model/Order/Pdf/Items/Invoice/Default.php different ways.

The attribute i try to call is "vpe" and is located after // custom options All I get is an empty value. By the way: the attribute must be called from the correct shop. In shop A i do not use this VPE. The invoice is from shop B and VPE is used on all products (its visible on the AdminHtml page) These ways did not work:

1)

  $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $this->getSku($item), array('vpe'));
     if ($product) {
          $lines[][] = array(
               'text'  => 'vpe:'.$product->getData('vpe'),
               'feed'  => 34
          );
     }

2)

$_item = $this->getItem();
$_item->setStoreId($_item->getInvoice()->getStoreId());

$storeId =  $_item->getStoreId();
$productId = $_item->getProductId();
$product = Mage::getModel('catalog/product')->load($productId);

$_vpe = $product->getData('vpe');

$attributes = $product->getAttributes();
$dispAttribs = array('vpe');
foreach ($attributes as $attribute) {...
        $attributeCode = $attribute->getAttributeCode();
        if(!in_array($attributeCode, $dispAttribs)) continue;
        $label = $attribute->getFrontend()->getLabel($product);
        $value = $attribute->getFrontend()->getValue($product);

            $_vpe = $value;
}


$lines[][] = array(
    'text' => Mage::helper('core')->__('vpe: ') . $_vpe,
    'feed' => 34
);

Using Magento 1.7.0.1

EDIT:

I found another way to try:

$product = Mage::getModel('catalog/product')->setStoreId($item->getStoreId())->loadByAttribute('sku', $this->getSku($item));
$attribute = $product->getResource()->getAttribute('vpe');
if ($attribute)
{
    $_vpe = $attribute ->getFrontend()->getValue($product);
}
$lines[][] = array(
     'text'  => 'vpe:'.$_vpe,
     'feed'  => 34
);

After inserting this i get some VPE but from the wrong shop. any ideas?

1
  • This question is NOT duplicate, because i need to know how i can get the information from different shops.
    – DvdEnde
    Commented Oct 16, 2014 at 8:50

1 Answer 1

-1

hi try this add store code product obejct

 $product = Mage::getModel('catalog/product')->setStoreId($item->getStoreId())->loadByAttribute('sku', $this->getSku($item));

then you can get Product:

$product->getData('vpe')

try this

 $product->getResource()->getAttribute('universo_store')->getFrontend()->getLabel($product);
1
  • thx Amit, but the value is still empty. I put in this: $product = Mage::getModel('catalog/product')->setStoreId($item->getStoreId())->loadByAttribute('sku', $this->getSku($item)); if ($product) { $lines[][] = array( 'text' => 'vpe:'.$product->getData('vpe'), 'feed' => 34 ); } BUT its writing the text vpe only. not the value i also expect
    – DvdEnde
    Commented Oct 7, 2014 at 10:00

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