Just a really basic but it works
In MODx resource I add snippet call:
[[!prestaCat? &categ=`1`]]
where &categ is the category ID I want to get.
Then you create chunk 'prestaTpl' - for example mine:
<img src="http://domain.com/prestashop/img/p/[[+id]]-[[+image]]-medium.jpg" align="left" />
<h4><a href="http://domain.com/prestashop/product.php?id_product=[[+id]]">[[+name]]</a></h4>[[+shortdesc]]<p>Available text: [[+available]]
Price: [[+price]] €</p>
And create snippet 'prestaCat' and change Prestashop DB details:
$db_hostname = "localhost";
$db_username = "dbuser";
$db_password = "passssss";
$db_database = "dbname";
$db_server = mysql_connect($db_hostname, $db_username, $db_password);
if (!$db_server) die("Unable to connect to MySQL: " . mysql_error());
mysql_select_db($db_database) or die("Unable to select database: " . mysql_error());
$result3 = mysql_query("SELECT * FROM ps_category_product WHERE id_category='$categ'")
or die(mysql_error()); if (!$result3) die ("Database access failed: " . mysql_error());
while($row3 = mysql_fetch_array( $result3 )) {
$id = $row3['id_product'];
$result2 = mysql_query("SELECT * FROM ps_product_lang WHERE id_product='$id'");
while($row2 = mysql_fetch_array( $result2 )) {
$name = $row2['name'];
$desc_short = $row2['description_short'];
$available = $row2['available_later'];
$result = mysql_query("SELECT * FROM ps_product WHERE id_product='$id'");
while($row = mysql_fetch_array( $result )) {
$price = sprintf('%0.2f', $row['price']);
}//end while 'Price'
$result_i = mysql_query("SELECT * FROM ps_image WHERE id_product='$id'");
while($row_i = mysql_fetch_array( $result_i )) {
if ($row_i['position'] == 1) $image = $row_i['id_image'];
}//end while 'Image'
if ($row2['id_lang'] == 6) $send = $send . $modx->getChunk('prestaTpl',array(
'image' => $image,
'id' => $id,
'name' => $name,
'shortdesc' => $desc_short,
'available' => $available,
'price' => $price,
));
}//end while 'Products in right category'
}//end while 'Get product IDs in right category'
mysql_close($db_server);
return $send;
Very primitive. I didn't get Prestashop SEF friendly URLs working so must modify the code if you have SEF URLs working.
Also, there's one issue I'm not sure how to fix - it takes from Prestashop database öäüõ characters as �. One idea is that xPDO should be used but I'm not that advanced yet. Rather wrote it as a test if it'll work.