Jump to content

Pedram

Members
  • Posts

    20
  • Joined

  • Last visited

About Pedram

  • Birthday 05/03/1994

Profile Information

  • First Name
    Pedram
  • Last Name
    Saeedi
  • Activity
    Developer

Recent Profile Visitors

154,215 profile views

Pedram's Achievements

Rookie

Rookie (2/14)

  • Reacting Well Rare
  • Conversation Starter Rare
  • First Post Rare
  • Collaborator Rare
  • Dedicated Rare

Recent Badges

3

Reputation

  1. I just encounter this problem on a fresh 8.1.2 Demo site I created for my modules, But I dealt with this type before and it's very easy to fix. 👌 There is a new problem that start occurring since Prestashop 8, Sometimes some modules end up being disabled in some form but their override will not be removed from the root/override folder. This can happen when you upgrades the site and click on "Disable third Party Modules" too but it's not just limited to this and even a fresh install can have this problem. To fix this problem, not only for this module but for any modules that give you override related error, you can simply find the module and try Enabling it 2 time. So when you try to enable the module the first time, you see an error telling you the override for it already exist, but then prestashop will remove it and turn the module disabled again. Then you can click Enable again a second time and this time it will successfully add the override & enable the module, This will fix the error completely. For this thread's specific error, it come from Module "eShip for PrestaShop" so you need to try and enable this module 2 time to fix this error. I'm not German, so Apologize for writing in English, I used DeepL for this :
  2. I know this is several years old but this was #1 result in google when I searched for what alternative I use for Tab::getIdFromClassName function in Presta 8. Since it might be fully removed in P8+ versions soon, might be a good time to replace it. but most search results and even in documentations i could not easily find a clear answer. This illegal static call just need you to make a instance from that class for it to fix, but I don't believe this is the correct thing to do. $tabRes = new TabRepository(); $tab_id = $tabRes->findOneIdByClassName("MyClassName"); after checking some more places including the Github, I found the correct method is to get the current instance of TabRepository instead of making a new one is the corect answer. So Instead of using Tab::getIdFromClassName in newer versions of Prestashop, we can use this code and avoid the deprecated error as well : SymfonyContainer::getInstance()->get('prestashop.core.admin.tab.repository')->findOneIdByClassName('MyClassName');
  3. it might have been. Thanks. I did delete the Prod and Dev folder before a few time after the update from 1.7 to 8.1. but I didn't do any cache cleaning while editing for this problem yesterday. mostly coz I thought mainly the .js files and sometimes .tpl files are cached and need cleaning and didn't realize .php files might need it too.
  4. Okay, so I got this to work somehow. The problem is, I'm not sure how I got it to work in the end... My progress last night lead me to checking and working on the loadRoutes function inside Dispatcher.php which might redefine the "rule" value of the route, but I didn't change anything yet and sleep. Today I just started by resetting and disable and re-enabling a bunch of SEO modules and then it just started working by itself... without me changing anything. So I assume it was a weird problem happening due to the auto upgrading from 1.7 to 8.1 and it somehow fixed itself after something got reset somewhere. Still if anyone got any advice on anything in this topic or something I might have gotten wrong, feel free to comment, I'm always open to learn for the future Thanks.
  5. Hello. I'm upgrading my site from 1.7 to 8.1 (working on a copy of my site on localhost atm) There was around a hundred modules, some auto upgraded and some i manually upgraded and bug fixed all to work on 8.1 the only one I could not fix was a SEO module that changed the Categories from the default being {id}-{Category_Name} into /Category-parent/Category-name/ So I checked on how it did this, and I notice it did it by overriding the Dispatcher.php file that can be found in the "Classes" folder. First I tried to fix that, but after a few try, I wanted to check if the Override itself is the problem or not. So I first went and removed that module's override file and then directly edited the Dispatcher.php file from Prestashop core files. \classes\Dispatcher.php https://github.com/PrestaShop/PrestaShop/blob/develop/classes/Dispatcher.php#L63 but no matter what I change, it actually won't change the routing... So at this point I'm not sure if the problem is the module's override, rather it might be Presta 8 is not using this routing code anymore ? or is it overwriting this somewhere else ? is there any clue that could help me here ? I have made custom routing modules before, so I'm going on by that same assumption here. since when I made custom routing for my module before, I simply set the rule to the url pattern I wanted it to show and it worked. but here it wont work by editing the rule section. making me suspect it might be a new Presta 8 change. We got this : 'category_rule' => [ 'controller' => 'category', 'rule' => '{id}-{rewrite}', 'keywords' => [ 'id' => ['regexp' => '[0-9]+', 'param' => 'id_category'], 'rewrite' => ['regexp' => self::REWRITE_PATTERN], 'meta_keywords' => ['regexp' => '[_a-zA-Z0-9-\pL]*'], 'meta_title' => ['regexp' => '[_a-zA-Z0-9-\pL]*'], ], ] the rule being {id}-{rewrite} is basically what will show up in front office. So just for testing, I made it like this : 'category_rule' => [ 'controller' => 'category', 'rule' => 'categorytest/{id}-{rewrite}', 'keywords' => [ 'id' => ['regexp' => '[0-9]+', 'param' => 'id_category'], 'rewrite' => ['regexp' => self::REWRITE_PATTERN], 'meta_keywords' => ['regexp' => '[_a-zA-Z0-9-\pL]*'], 'meta_title' => ['regexp' => '[_a-zA-Z0-9-\pL]*'], ], ] but nothing actually happened. it still works same as before. Address is still "MySite.com/id-categoryname" in my site. it does not even fail to load or any error, it works as if my change here is overwritten back to default somewhere else. but this code is not completely unused either, coz if I simply remove it or change the route name (category_rule), then the whole rewriting for categories simply stop working and the url change back to the original "index.php?controller=category_rule&id={id}&rewrite={Name}" So this is indeed being used by prestashop to pick up the rule for rewriting the categories... but the "rule" section of it seems to not matter what edit i make, always stay the same... So Long story short, Any Idea where I need to edit to make fix my categories routing ? or I could simply delete this old 3rd party module and make my own if there is a better, newly recommended way of me changing my category routing from the default to "/category-parent/category-name" type of address. Any Advice is appreciated. Thanks.
  6. I know this is kinda old, but I found this page in google, which mean others might find it too, So I might as well answer it. Simply add this either in a .js file or include it in your tpl/twig file between a <script></script> tag that you want to have popover working. $(function () { $('[data-toggle="popover"]').popover() }); popover in bootstrap is not active by default and need to be activated like this anytime you want to use it. You can check other options here: https://getbootstrap.com/docs/4.0/components/popovers/
  7. Hmm, How are you creating these myshop.com/specialBlogPage urls ? if they are CMS pages, IIRC there should be some built-in feature in the Prestashop to redirect them to your custom URL. But instead, if you are creating them using your module controller, like the content of the page might change depend on the parameters value, For example controller is "Blog", and parameter is "Page" and value is "special" then it will open your special blog page. Then you can add routes using "moduleRoutes" in your module for them. First, Make a module or go to this link to generate a simple one : https://validator.prestashop.com/generator Second, Add this Hook to the install section : $this->registerHook('moduleRoutes') Third, Add this section to your module code in same file (YourModuleName.php) as the install section above : public function hookModuleRoutes($params){ $my_routes = array( 'YourRouteName1' => array( 'controller' => 'NameOfController1', 'rule' => 'blog/{id}-{name}/', 'keywords' => array( 'id' => array('regexp' => '[\w]+', 'param' => 'id'), 'name' => array('regexp' => '[\w]+', 'param' => 'name'), ), 'params' => array( 'fc' => 'module', 'module' => 'YourModuleName' ) ), 'YourRouteName2' => array( 'controller' => 'NameOfController2', 'rule' => 'branchelets/{id}-{name}', 'keywords' => array( 'id' => array('regexp' => '[\w]+', 'param' => 'id'), 'name' => array('regexp' => '[\w]+', 'param' => 'name'), ), 'params' => array( 'fc' => 'module', 'module' => 'YourModuleName' ) ) ); return $my_routes; } This will make it that instead of MyShop.com/Modules/YourModuleName/?Controller=NameOfController1&id=43&name=Yes-very-special (If friendly URL turned on) Your page will show up as myshop.com/blog/43-yes-verry-special Same goes for the 2nd URL. MyShop.com/Modules/YourModuleName/NameOfController2/id=23&name=saphires-and-ruby-bracelet --> myshop.com/brachelets/23-saphires-and-ruby-bracelet
  8. Hello, I've been developing a module to add a "Daily Limit" to customer purchase and basically prevent them from completely adding any product in their shopping cart if it surpass that daily limit. It all went mostly smoothly, except 2 problem I encountered, How do I prevent the item to be added to the shopping card from the "actionCartUpdateQuantityBefore" hook. Why is one of my sites still let customer add an item to their shopping cart but another site does not, even tho both of these sites have the same Stock management setting of not allowing backorder. I will briefly explain what I did for this module: What I did was, add this hook "actionCartUpdateQuantityBefore" to the module, then check where this hook is called, it's from Cart.php, checking the parameters and some code, the important parts is this: $data = array( 'cart' => $this, 'product' => $product, 'id_product_attribute' => $id_product_attribute, 'id_customization' => $id_customization, 'quantity' => $quantity, 'operator' => $operator, 'id_address_delivery' => $id_address_delivery, 'shop' => $shop, 'auto_add_cart_rule' => $auto_add_cart_rule, ); /* @deprecated deprecated since 1.6.1.1 */ // Hook::exec('actionBeforeCartUpdateQty', $data); Hook::exec('actionCartUpdateQuantityBefore', $data); if ((int) $quantity <= 0) { return $this->deleteProduct($id_product, $id_product_attribute, (int) $id_customization); } if (!$product->available_for_order || ( Configuration::isCatalogMode() && !defined('_PS_ADMIN_DIR_') ) ) { return false; } As you can see from the code above, I get the $data and I used them in my module to check if the user surpassed the daily limit or not. if the "price of his purchase today" + "price of the shopping card" + "price of the product" he is trying to add, is not above the daily limit. Do nothing, otherwise, some new data will be shown using the "displayCartModalContent" to tell them of the daily limit which works fine. Now we reach the first problem: How do I prevent the item to be added to the shopping card from the "actionCartUpdateQuantityBefore" hook. To solve this above problem, I did a simple trick, I simply write $data['product']->available_for_order = false; once this data is changed in my module hook, then the Cart will be returned false. due to this: if (!$product->available_for_order || ( Configuration::isCatalogMode() && !defined('_PS_ADMIN_DIR_') ) ) { return false; } which should work fine, and it indeed worked fine in localhost and my first site, Prestashop Version 1.7.6.4. But then I tried to install this in my 2nd site, which a few years ago was the clone of the first site, but changed a bit over time, and it's Version 1.7.6.5 right now. in this site, while both the "action" and "display" hook from my module works perfectly, The customer can still add the item to it's shopping cart... They see my daily limit error from my display hook showing up and telling them they are over the limit. But their shopping cart still add the product regardless of that. To completely make sure this is not my module's problem, I created a product out of stock, then using a customer account, tried to add it to cart, the button is "disabled" but a simple right click and Inspect Elements, removing the "disabled" attribute from the button and you can click it. Then it will actually add the product to my shopping cart! this is a problem. Same trick does not work in first site, it give an error and does not add the product. Both site seems to have similar settings and configuration, the only difference is Version 1.7.6.4 on first and Version 1.7.6.5 on second site. Any Idea ? Also, is there another way I could use to prevent a product from being added to the shopping cart from the "actionCartUpdateQuantityBefore" hook ? Thanks in advance. Edit: I might as well add that I rather do this simply from my module and without touching any of Prestashop core files or overriding anything.
  9. I did not find the solution, but the site admin asked a php prestashop programmer that he knew and apparently he fixed it very quickly. Sadly my friend don't understand programming himself and I didn't directly talk with the programmer, So I never figured out what was the problem. I suspect there was a problem inside the Key Manager Module itself as I later realize changing anything using API will automatically update every standard/base prestashop properties or trigger their events but sometimes have problem with 3rd party modules.
  10. Hello, I have a question, I want to know is there a difference between changing an order status using an api key or manually going to the backoffice and changing it ? I'm not exactly sure where is the problem, if it's the module I am using or a prestashop limitation or setting I need to change. To explain it briefly, I made a program that will process customer orders, check with the bank and everything, after it finish all the validations and confirmation, It will change the Order Status to "Payment Accepted". Ideally, This should trigger the module (Key Manager) to send the digital product to the customer. But while it works perfectly when I change and order status to "Payment accepted" from Back-office. it does not work when I do the same thing from API. Any idea what's the problem ? The api successfully change my Order status without any problem, but for Key Manager to work, I need to do it in backoffice manually. On a side note, the api I wrote is not in php but in C#, Unfortunately I have a very basic knowledge of the php language, so any advice or help will be greatly appreciated. Thanks.
  11. Hi, Thanks for reply, I read about Actions hooks before briefly , I know they can Do something after something else is done , like an Event in C#. But the problem is that I have no idea , how i can make an action hook send something to my .net app. Well, the only way i can think of is sending a POST to a IP or url , which my .net app is located, but it will be the same as my second method I guess ? coz my program have to be on constant check to receive the POST or something ... btw I forgot to mention, If it was a .net Web Application I knew what to do, but it's a Windows Application.
  12. hmmm UK is Europa country so the Europa Paypal Module should work i guess : http://addons.prestashop.com/en/payments-gateways-prestashop-modules/1748-paypal.html I wanted one for Emirate but i could not find but Euro and US there is free ones .
  13. Hello, I'm a .net Developer , as well as a Prestashop owner, I have already made a program to do everything i need in C# and Automate all my work, The only part which is not automated yet is that i have to manually check site for Order Details and Status and give it to my C# Application. So i have 2 approach in my mind , but I want advice on which is better or is there any better way other than this two ? So my first idea is, I can set some timer or something on my app and use prestashop's webservice and check for the new Orders, when app hit a new Successful Purchase, it would then take the info and proceed to do the rest of the works. and my 2nd idea , well it came from the Telegram Bot I made last months for my site . just like how it sent new updates through a Json string from a link, I could do the same and make a secret url that show empty results {"ok":true,"result":[]} until there is a new successful purchase which would show up with the details in the result section , and my App would then proceed to do the works and send back a POST to my link to remove the result back to empty [ ]. So which one of these methods is best or is there any better idea ? also is there a way to make a call to the application only when we got a new Successful purchase ? btw, my knowledge of php is not advanced, my best ever creation yet in php, was a custom payment method modules for prestashop. but I'm good at C#. Thanks.
  14. Ok not Sure what the problem was, but i take this chance and upgraded my Prestashop from 1.6.0.6 to 1.6.0.14 and by doing so , it fixed my problem and now it works lol Tnx anyway
  15. ' no i didn't do that coz files in cachefs were not dated for today or yesterday but 9 may or so Update Edit : Ok not Sure what the problem was, but i take this chance and upgraded my Prestashop from 1.6.0.6 to 1.6.0.14 and by doing so , it fixed my problem and now it works lol Tnx anyway
×
×
  • Create New...