Jump to content

dtbaker

Members
  • Posts

    4
  • Joined

  • Last visited

About dtbaker

  • Birthday 01/01/1

dtbaker's Achievements

Newbie

Newbie (1/14)

11

Reputation

  1. I've done this, it's a bit hard to explain because we've got a custom theme, but below is the php code and template code to get the "from" thing working. Quite a bit of code because it has to check if each attribute affects the price. In category.php this is what the code looked like "before": if ($category->id != 1) { $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true); include(dirname(__FILE__).'/pagination.php'); $smarty->assign('nb_products', $nbProducts); $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay); } and this is what it looks like "now": if ($category->id != 1) { $nbProducts = $category->getProducts(NULL, NULL, NULL, $orderBy, $orderWay, true); include(dirname(__FILE__).'/pagination.php'); $smarty->assign('nb_products', $nbProducts); $cat_products = $category->getProducts(intval($cookie->id_lang), intval($p), intval($n), $orderBy, $orderWay); foreach($cat_products as &$cat_product){ $cat_product['all_prices'] = array(); $product = new Product($cat_product['id_product'], true, intval($cookie->id_lang)); $cat_product['all_prices'][] = floatval($cat_product['price']); $attributesGroups = $product->getAttributesGroups(intval($cookie->id_lang)); if (Db::getInstance()->numRows()) { $combinationImages = $product->getCombinationImages(intval($cookie->id_lang)); foreach ($attributesGroups AS $k => $row){ $cat_product['all_prices'][] = floatval($cat_product['price']) + floatval($row['price']); } } $diff_prices = array_unique($cat_product['all_prices']); array_multisort($diff_prices); $cat_product['from_price'] = (count($diff_prices)>1) ? array_shift($diff_prices) : false; } } Then in themes/your_theme/product-list.tpl this is what it might have looked like before: {convertPrice price=$product.price} and this is what i changed it to. {if $product.from_price}from {convertPrice price=$product.from_price}{else}{convertPrice price=$product.price}{/if} Examples: http://bastbodyjewellery.com.au/7-eyebrow-jewellery http://bastapparel.com.au/18-punk-accessories
  2. See this post: http://www.prestashop.com/forums/viewthread/7273/installation_configuration___upgrade/error_when_saving_new_products/ If your product or descriptions contain any of these words it will fail: UNION|LOAD_FILE|OUTFILE|DUMPFILE|ESCAPED|TERMINATED|CASCADE|INFILE|X509|TRIGGER|REVOKE
  3. Found the problem! my customer has been trying for a week to insert a product called "Cacsade Bonsai Pot" and it has been throwing this cryptic error message: " an error occurred while creating object product " I upgraded his version of prestashop, and it was still causing issues. Finally tracked the problem down It's in prestashops query blacklist checker: private static $_blacklist = 'UNION|LOAD_FILE|OUTFILE|DUMPFILE|ESCAPED|TERMINATED|CASCADE|INFILE|X509|TRIGGER|REVOKE'; public static function blacklist(&$query) { return eregi(self::$_blacklist, $query) ? true : false; } It thinks the "Cascade" in the product name & description is a harmful SQL query! The solution is: * SHRUG * I've just removed "CASCADE" from the blacklist checker so my customer can create this product, hopefully newer versions of prestashop will have a nicer sql parser, possibly something that strips out all user values between "[^"]*" or '[^']*' before checking the query. ? Dave
×
×
  • Create New...