Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Page 1 of 2
Display Attributes on Invoice or Packing Slip
 
Mad Martigan
Member
 
Total Posts:  44
Joined:  2008-08-17
Medford, OR USA
 

I’m modifying Shipping.php to try and add an attribute to the packing slip Pdf.  The attribute is not a custom attribute for the product but rather a standard attribute with type “text” and assigned to the default attribute class.  The attribute name is ‘location_shelf’ and it stores an integer.

So, here is what I am doing to try and get it to show up.....

$page->drawText($item->getData(’location_shelf’), 70, $this->y - 40, ‘UTF-8’);

This line works with other attributes such as weight, but it does not work with my attribute.  I’m certain there is a class that is used to get extended attributes, but I cannot find it.  I’ve tried A LOT! smile

Any help is greatly appreciated.  Thank you.

Marty

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mad Martigan
Member
 
Total Posts:  44
Joined:  2008-08-17
Medford, OR USA
 

I feel like I’m getting close. 

I’m working in file app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php

I think the syntax may be something like this....

$myAttributeArray $this->getItemOptions();
$myAttributeValue $myAttributeArray['myAttributeName'];
$page->drawText($myAttributeValue6060'UTF-8');

But unfortunately the array is empty.  I’m really stuck on this one.  I’ve been banging my head against it for 2 days and I just cannot seem to understand how to get an array of item options into a variable.  I’ve tried thousands of permutations of the syntax and I still come up empty.  This one is driving me nuts.

I would imagine it would be similar to what we do on the front end such as....

$_product->getData('some_attribute_name')

Any ideas....anyone.......anyone? 

smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mad Martigan
Member
 
Total Posts:  44
Joined:  2008-08-17
Medford, OR USA
 

Just in case anyone else is trying to accomplish this I thought I would post my progress (which is very little).

Here is the hacked-up, very inneficient code that I use to get an attribute onto the packing list PDF.

//instantiate the class
$products Mage::getModel('catalog/product')->getCollection();
//add the Attribute
$products->addAttributeToSelect(array('row','shelf','bin'), 'inner');
//walk the collection
foreach($products as $product){
    
if ($item->getSku() == $product->getSku() ) {
        $aa 

        
"Row:"   $product->getRow() .
        
"Shelf:" $product->getShelf() .
        
"Bin:"   $product->getBin();
        
$page->drawText($aa35$this->y-20'UTF-8');
        break;
    
}
}

Yep, you see that correctly.  I am cycling through every single sku in the store just to pull out attributes for a single sku.  I’m doing this only because I cannot find a way to pull attributes for a single item any other way. 

Anyway, that’s how desperate I am.  smile

If anyone has a simple way to do this, I’d love to see a code snippet.

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

Well, i see several solutions to your problem, but I will answer your direct question, and if you like I can explain some other possibilities later.

Try this

$productId Mage::getModel('catalog/product')->getIdBySku($item->getSku());
$product Mage::getModel('catalog/product')->load($productId);
or
$product Mage::getModel('catalog/product')->loadByAttribute('sku'$item->getSku());
or
$product Mage::getModel('catalog/product')->loadByAttribute('sku'$item->getSku(), array('row''shelf''bin'));

I haven’t tested those, so YMMV.

 
Magento Community Magento Community
Magento Community
Magento Community
 
LeeSaferite
Guru
 
Avatar
Total Posts:  322
Joined:  2007-08-31
Lake City, FL
 

Actually, I think the last example I sent you is the best one in your current case

$product Mage::getModel('catalog/product')->loadByAttribute('sku'$item->getSku(), array('row''shelf''bin'));

It will use the SKU attribute to filter the products, return the first one, AND add your attributes to the select.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Mad Martigan
Member
 
Total Posts:  44
Joined:  2008-08-17
Medford, OR USA
 

Lee.....you are my HERO!!!!!!!

Thank you VERY MUCH for that great example.  You are correct, the last example works perfectly for my needs.  I really appreciate that you took the time to reply, it made my day, thanks again! 

Marty

 
Magento Community Magento Community
Magento Community
Magento Community
 
da.v.id
Jr. Member
 
Total Posts:  9
Joined:  2008-09-30
 

Hi this is exactly what I want to do, however I want to add manufacturer to the picking note. I’m new to magento, and I know very little php, but I was wondering if anyone could explain how / where I would put in a line similar to the one shown above to do this. If anyone has some time to help, it would be greatly appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jkea
Jr. Member
 
Total Posts:  2
Joined:  2008-10-17
 

I am interested in displaying the manufacturer in the product listing as well; outside of the module provided to do so. Does anyone know what syntax to use to display the manufacturer attribute “anywhere” on a page?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Emilie
Jr. Member
 
Total Posts:  16
Joined:  2008-09-15
 

hi guys,

i try to modify app/code/core/Mage/Sales/Model/Order/Pdf/Items/Shipment/Default.php file. but nothing happen. and also nothing happen when i delete this file.
i can make changes to other i try to modify app/code/core/Mage/Sales/Model/Order/Pdf/ files but not with Default.php files.

it’s really stange, somebody have an idea ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
play2game
Jr. Member
 
Total Posts:  8
Joined:  2008-04-09
 

Hi,
we need to add the total amount of the order in the packing slip, in order to let the mail guy know the amount to collect when customers choose to pay in delivery.
we are really stuck on this, if anyone could help....

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
dm06
Jr. Member
 
Total Posts:  5
Joined:  2008-07-27
 

I needed to add attribute information to the order confirmation the customer can print and apart from the formatting code this is what I added to app/design/frontend/mystore/default/template/sales/order/item/renderer/default.phtml:

<?php $my_product = Mage::getModel('catalog/product')->loadByAttribute('sku', $_item->getSku(), array('dimension')); ?>
<?php echo $my_product->getData('dimension') ?>

This displays the information need and avoids modifying the php files, the trick is to find the right item renderer for the different pages

 
Magento Community Magento Community
Magento Community
Magento Community
 
svachet
Jr. Member
 
Total Posts:  2
Joined:  2009-01-30
 

Oh huzzah. DM06’s syntax above, plus the getAttributeText() from this thread http://www.magentocommerce.com/boards/viewthread/19215/P0/, just saved me from many many hours of hair-pulling!

 
Magento Community Magento Community
Magento Community
Magento Community
 
cbmegahan
Jr. Member
 
Total Posts:  7
Joined:  2009-06-04
 

Does anyone have the full code for this? I’m not a complete idiot with PHP but I’m not having luck implementing this for my ‘shelf_code’ attribute.  Thanks!

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pooch
Member
 
Total Posts:  70
Joined:  2008-05-15
Danville, CA USA
 

This is driving me nuts! Can’t seem to get it to work.

I’m trying to add a manufacturer attribute to each of the items on the invoice to no avail. I’ve tried the suggestions above but they don’t seem to work. I feel like I need to add the manufacturer attribute to XML somwhere but I don’t know where. Any ideas anyone?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Pooch
Member
 
Total Posts:  70
Joined:  2008-05-15
Danville, CA USA
 

Finally got it! Turns out in order to get the code above to work for me in 1.3.2.3 I had to go to the attribute I wanted (manufacturer) and set “Used in product listing” to yes! Hope that helps someone.

 
Magento Community Magento Community
Magento Community
Magento Community
 
fanta00
Jr. Member
 
Total Posts:  28
Joined:  2009-11-23
 

Could anyone post here a finished code to output attributes (also with drop-downs like manufacturer) on the invoice?
thank you

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2