-
Posts
17 -
Joined
-
Last visited
cracked's Achievements
Newbie (1/14)
6
Reputation
-
I found a solution for this problem as well: If smartyRegisterFunction is bringing this or a similar output to your apache error log (resulting in HTTP Error 500) then try this fix: Modify /config/smary.config.inc.php like this: function smartyRegisterFunction(&$smarty, $type, $function, $params, $lazy = true) { if (!in_array($type, array('function', 'modifier', 'block'))) { return false; } if(is_null($smarty)) $smarty = $GLOBALS['smarty']; if(is_null($smarty)) return false; Just return false if there is no "$smarty". Works like a charm.
-
The problem was also caused by this: https://www.prestashop.com/forums/topic/616266-ps-16xx-vistors-cant-find-products-by-search/?tab=comments#comment-2573712 Visitors (but in our case: business customers) weren't allowed to "see" this products - prestashop has a bug when you define another group as the default group for visitors. Check my other topic for fixing this.
-
which syntax errors do you mean? You can use google chrome. I do and it works just fine. But we had to make some code changes too.
-
I looked up the redirects for myself, as your explanation wasn't clear... To me this looks like it should: What exactly is your problem now? Regards, cracked
-
Hello guys, it's me again, today with another definitive bug report for prestashop 1.6.x.x (even the most recent version 1.6.1.4 does no better). We recently hit the problem that our users / visitors couldn't find products when using prestashops standard search function. Everything in the backend was set up correctly and for logged in users everything works as expected, so I needed to debug this case. Fortunately it wasn't hard to find. In Prestashops backend you have the following option: As you can see, you are able to define which customer group is used for a customer when he is not logged in (visitor). In our case we chose the group "business customers" with id=5. You can define this for a specific shop or all shops, but this doesn't matter - because it doesn't work. And I can show you why: In class SearchCore / Search.php you'll find the following code: $sql_groups = ''; if (Group::isFeatureActive()) { $groups = FrontController::getCurrentCustomerGroups(); $sql_groups = 'AND cg.`id_group` '.(count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); } The problem lies in FrontController::getCurrentCustomerGroups(); /** * Sets and returns customer groups that the current customer(visitor) belongs to. * * @return array * @throws PrestaShopDatabaseException */ public static function getCurrentCustomerGroups() { if (!Group::isFeatureActive()) { return array(); } $context = Context::getContext(); if (!isset($context->customer) || !$context->customer->id) { return array(); } if (!is_array(self::$currentCustomerGroups)) { self::$currentCustomerGroups = array(); $result = Db::getInstance()->executeS('SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)$context->customer->id); foreach ($result as $row) { self::$currentCustomerGroups[] = $row['id_group']; } } return self::$currentCustomerGroups; } Here you can see on line 1203 that if "$context->customer" is not set, and neither "$context->customer->id" is, then an empty array is returned. Back to Search.php: $sql_groups = 'AND cg.`id_group` '.(count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); If $groups is empty, then 1 will be used. Group 1 is the standard visitors group. So this works fine, as long as you use the standard visitors group. But if you define another visitors group like in our case the "business customers"-group with id 5, then this has no effect. And its clearly a bug. Thanks and regards, cracked
-
[PS1.6.1.5] Link::getProductLink not working properly?
cracked replied to cracked's topic in Core developers
Hello Guys, months later but I finally found out what exactly the problem is - and got the solution. Please keep in mind that we use a multi-store, so this problem only applys when you want to get product links for different stores inside a multistore. So, there are several ways to generate a product link in prestashop. The constructor of class Product looks like this: public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null) So you would create a product object like this: $product = new Product(826, false, 2, 1); Now you could get the product-link for this product by simply using $product->getLink(); or you could do it this way: #getProductLink header: #public function getProductLink($product, $alias = null, $category = null, $ean13 = null, $id_lang = null, $id_shop = null, $ipa = 0, $force_routes = false, $relative_protocol = false, $add_anchor = false) #this is how you could also generate the ProductLink Context::getContext()->link->getProductLink($product,null,null,null,$id_lang,1); which works fine as far as you want to create the link for shop id = 1. But as you can see, Link::getProductLink's 6th parameter is $id_shop. So one, like me, could get the idea that you can simply create the product link for lets say, shop id = 3 like this: #the 6th parameter is shop_id. Here I try to create the link for shop id = 3 Context::getContext()->link->getProductLink($product,null,null,null,$id_lang,3); Which doesn't work, when your shops have different home categories. But why? It's because this part of code inside of getProductLink: if ($dispatcher->hasKeyword('product_rule', $id_lang, 'categories', $id_shop)) { $params['category'] = (!$category) ? $product->category : $category; $cats = array(); foreach ($product->getParentCategories($id_lang) as $cat) { if (!in_array($cat['id_category'], Link::$category_disable_rewrite)) { //remove root and home category from the URL $cats[] = $cat['link_rewrite']; } } $params['categories'] = implode('/', $cats); } Precisely line 146 $product->getParentCategories is the problem. As $product was generated with shop_id = 1, getParentCategories will find and use all parentCategories of shop_id = 1, even though you wanted to create a link for shop_id = 3. Now the solution could be simple. Generate a new $product object with shop_id = 3. But i think this is very inefficient and bothering, first because we use multi shop and every time I want the product link I have to generate a new object for each shop and SECOND, because Link::getProductLink already has the parameter id_shop BUT IT DOESN'T WORK AS EXPECTED. For me, this is a bug in prestashop. I fixed this for myself by overwriting Link.php and altering the code like this: #overwritten Link.php: ... if ($dispatcher->hasKeyword('product_rule', $id_lang, 'categories', $id_shop)) { $params['category'] = (!$category) ? $product->category : $category; $cats = array(); foreach (Link::getParentCategories($product->id, $id_lang, $id_shop) as $cat) { if (!in_array($cat['id_category'], Link::$category_disable_rewrite)) { //remove root and home category from the URL $cats[] = $cat['link_rewrite']; } } $params['categories'] = implode('/', $cats); } ... function getParentCategories($id_product, $id_lang = null, $id_shop = null) { if (!$id_lang) { $id_lang = Context::getContext()->language->id; } //taken from Shop.php addSqlRestrictionOnLang if (isset(Context::getContext()->shop) && is_null($id_shop)) { $id_shop = (int)Context::getContext()->shop->id; } if (!$id_shop) { $id_shop = (int)Configuration::get('PS_SHOP_DEFAULT'); } $defaultCatSql = 'select id_category_default from '._DB_PREFIX_.'product_shop where id_product = '.$id_product.' and id_shop = '.$id_shop; $idDefaultCat = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($defaultCatSql)[0]['id_category_default']; $interval = Category::getInterval($idDefaultCat); $sql = new DbQuery(); $sql->from('category', 'c'); $sql->leftJoin('category_lang', 'cl', 'c.id_category = cl.id_category AND id_lang = '.(int)$id_lang.' AND cl.id_shop = '.$id_shop); $sql->where('c.nleft <= '.(int)$interval['nleft'].' AND c.nright >= '.(int)$interval['nright']); $sql->orderBy('c.nleft'); return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } Now I can use Link:getProductLink as expected, with a $product object which doesn't matter with which shop_id it was generated. Hope this helps someone else. Regards, cracked -
Hi, we have a problem with the ajax autocomplete in the search bar. I made a video showing the problem. when typing beyond "migr" it certainly still should find all the products, shown before. Even for "migration" 4 products should be found, but none are. The search index was fully rebuilt and all products are indexed as for now, but this problem remains. Check it out for yourself at https://my-lab.com/analytics/b2b/de/lebensmittel/ Regards
-
Hi guys, in our specific case the error log of the server shows, that this problem lies within a module called "Advanced SEO Friendly URLs Module" or "fsadvancedurl". https://addons.prestashop.com/en/url-redirects/19643-advanced-seo-friendly-urls.html I just can highly recommend to check the apache error log, as when a HTTP 500 Server Error occurs you don't get to see any output in your browser. So again, in our case the log shows the following: AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to a member function registerPlugin() on null in /var/www/vhosts/my-lab.com/httpdocs/analytics/config/smarty.config.inc.php:185\nStack trace:\n#0 /var/www/vhosts/my-lab.com/httpdocs/analytics/modules/fsadvancedurl/classes/FsAdvancedUrlModule.php(72): smartyRegisterFunction(NULL, 'modifier', 'fsauCorrectTheM...', 'unescapeSmarty')\n#1 /var/www/vhosts/my-lab.com/httpdocs/analytics/modules/fsadvancedurl/fsadvancedurl.php(72): FsAdvancedUrlModule->__construct()\n#2 [internal function]: Fsadvancedurl->__construct()\n#3 /var/www/vhosts/my-lab.com/httpdocs/analytics/Core/Foundation/IoC/Core_Foundation_IoC_Container.php(124): ReflectionClass->newInstance()\n#4 /var/www/vhosts/my-lab.com/httpdocs/analytics/Core/Foundation/IoC/Core_Foundation_IoC_Container.php(157): Core_Foundation_IoC_Container->makeInstanceFromClassName('fsadvancedurl', Array)\n#5 /var/www/vhosts/my-lab.com/httpdocs/analytics/Core/Foundation/IoC/Core_Foundation_IoC_Container.php(170): Core_Foundation_I...\n', referer: https://my-lab.com/analytics/en/my-food/ So this proves that this module is responsible for the server error. Apparently it hooks so deep to prestashops core, that it can even crash my test-script on language switching, even when it's just including prestashops init.php. I have to say: impressive! Regards
-
Hello dear Devs, we have a problem lasting several months now, and have been ignoring it so far as it doesn't occur very often. When you switch the language in prestashop the page won't load, instead displaying you a HTTP 500-Server Error page. After that you can reload the page and it comes up normally like it should. This happens every single time you switch the language! 100% reproducible. Well now the funny part starts, as I just found out while writing a new script for a prestashop module, which doesn't use ANY prestashop functions so far, suddenly it shows the same behaviour. And its related to the language switching again. So I tried to nail it down and came up with this test-script: <?php /* include these prestashop files and the server will crash when setlocale-switch occurs */ include_once(dirname(__FILE__).'/config/config.inc.php'); include_once(dirname(__FILE__).'/init.php'); class Testclass { public function test() { if (isset($_GET['id_lang'])) $id_lang = intval($_GET['id_lang']); echo "using id_lang: ".$id_lang; if ($id_lang == 2) setlocale(LC_TIME, 'de_DE.utf8'); else setlocale(LC_TIME, 'en_US.utf8'); echo strftime('%B', mktime(0, 0, 0, 3, 1)); } } Testclass::test(); As soon as you include prestashops config.inc.php and init.php you'll see this error (Tested on 3 (!) different machines, with even slightly different setups), obviously you'll have to change the parameter script.php?id_lang=1 to script.php?id_lang=2 Any ideas why this happens? Is this the case for you too? PS: Make sure the locales used in this script are installed on your server. For us they can be used without any problems, other than this one described here. Regards, Lennart
-
[PS1.6.1.5] Link::getProductLink not working properly?
cracked replied to cracked's topic in Core developers
Hi again, yes they are indeed marked as root categories. (Is there a way to see this in Prestashops Backend?) This SQL-output should provide proof to the case: -
[PS1.6.1.5] Link::getProductLink not working properly?
cracked replied to cracked's topic in Core developers
Yeah, that could absolutely be the case, that this "Advanced SEO Friendly URL"-Module is causing all my problems. I'm in contact with one of their devs too, we'll see if we get an update. But as far as I can tell, Link::getProductLink() isn't overwritten by this module, neither any of the functions used by getProductLinkt(); The question remains if this is a general misconcept of this standard class/function that it just checks for "Configuration::get('PS_HOME_CATEGORY')" which will always return just one home category - but there can be many (in multistore). What do you think? Regards, Lennart -
[PS1.6.1.5] Link::getProductLink not working properly?
cracked replied to cracked's topic in Core developers
Hello Gabriel Perez, thanks again for your advice buddy, but I already came up with that idea too. Problem is, it ain't working: Regards, Lennart