strife's devLog

Tag: prestashop

prestashop-logoHow to Add a New Custom Field in Prestashop

I’ve figured out how to add new field to database using Prestashop (1.4.3, but I think for the newer versions would be the same). This solution gives you new field in database and you will be able to edit / save data to this field in your admin panel, for my example I needed a field which was called “number of photos”. Below you can see how it works.
Read the full article »

Share

prestashop-logoPrestashop, Paypal Module Message Limit 1600

When you have a problem with paypal module in Prestashop. I mean that kind of problem when user come back from paypal.com:

1
Fatal error (Message => message Length 1600)

You should edit Message.php (in classes) and change the limit of field. It’s line 54 and it should be look that:

1
2
// line 54
protected    $fieldsSize = array('message' => 16000); // just change to 16000

And then you won’t have any problem with limits when user come back to your internet store.

Edited (03/03/2012)
I’ve noticed there are a lot of people who are finding this information. In addition I want to tell this problem shouldn’t appear in the new version of paypal module.

Share

prestashop-logoGetting Cart From Prestashop

If you have a problem with getting cart from prestashop that would be interesting for you.

I had a huge problem with Prestashop (version 1.4.3) because I didn’t know how exactly I should get cart from Prestashop to the WordPress or somewhere else. However I spent some time to resolve that issue and I wrote that:

First of all we should get session data from Pretashop:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
require_once dirname(__FILE__) . '/config/config.inc.php' ;
require_once(dirname(__FILE__) . '/config/settings.inc.php');
require_once dirname(__FILE__) . '/init.php' ; // this initializes the Cookie singleton, which is available in any script
function getAllCookies(){
global $cookie ;
// var_dump($cookie);
return $cookie;
}
$cookie = getAllCookies();

As you see you should add some lines from Prestashop configuration and then you should create a function in which you have cart ID. And then you can easily get all data from the cart:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$query = "SELECT p.id_product, pl.name, p.quantity, pp.price, p.id_product_attribute, pp.price * cu.conversion_rate AS orderprice, cu.sign, cu.format FROM ps_cart c
LEFT JOIN ps_cart_product p ON (p.id_cart = c.id_cart)
LEFT JOIN ps_product pp ON (pp.id_product = p.id_product)
LEFT JOIN ps_product_lang pl ON (pl.id_product = p.id_product)
LEFT JOIN ps_currency cu ON (cu.id_currency = c.id_currency)
WHERE c.id_cart = " . (int) $cookie->id_cart . " AND pl.id_lang = 1
ORDER BY p.date_add ASC";
$link1 = mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
if ($link1) {
$db_selected = @mysql_select_db(_DB_NAME_, $link1);
$res = mysql_query($query);
$arrProducts = array();
while ($row = mysql_fetch_assoc($res)) {
$arrProducts[] = $row;
}
var_dump($arrProducts); // all products from session cart
}
mysql_close($link1);

(Sorry for quality of code but I had to wrote this as  quick as possible)

And that’s all :)

Share