Jump to content

[SOLVED] product attribute information truncated on pdf invoice


JuanTomas

Recommended Posts

Using P-Shop 1.6.1.1.

 

When you view a pdf invoice, the text in the Product column is the product_name properties of OrderDetail objects.  The product_name property consists of the name of the product, plus the names and values of all attributes of the product for that order, all concatenated into a single string.  Here's the code in classes/order/OrderDetail.php, in the create() function:

 

$this->product_name = $product['name'].
            ((isset($product['attributes']) && $product['attributes'] != null) ?
                ' - '.$product['attributes'] : '');
 

I had an order for a product with about six attributes, and the names and values of all those attributes were longish.  Taken all together, they added up to a string about 300+ characters long.  For some reason, the string was getting truncated at 255 characters when the pdf invoice was generated, so sales staff couldn't see exactly what the customer ordered.

 

The problem isn't in code, it's in the data model.  The database field product_name in ps_order_detail table is varchar(255).  This turned out to be a bit stingy, in my case.  I decided to alter the table to accommodate strings up to 1024 characters.  If you have the same problem, just execute the following query on your database (using phpMyAdmin or mysql) (check your database prefix, I'm using "ps_"):

 

ALTER TABLE `ps_order_detail` MODIFY `product_name` VARCHAR(1024)

 

After that, future invoices will display all the OrderDetail info.

Edited by JuanTomas (see edit history)
Link to comment
Share on other sites

  • 11 months later...

Thanks for this! 

 

On the newer version (1.6.1.6 or 1.6.1.7), the orders will actually fail in the back office.

 

The product text field includes the product name, all the combination text, as well as reference number.  If that field exceeds the 255 character limit, the order won't end up in the back office.

 

Instead, the order will show "Products 0", and the log will toss this error: "Frontcontroller::init - Cart cannot be loaded or an order has already been placed using this cart".

 

From the front office order processing point of view, the order went through, but the customers PDF invoice will have not have the item on it (price is correct though).

 

From the back office, you will get an order with the proper pricing, but the product is missing.  The shipping module breaks at this point since it has no sizes or weights.

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...