Jump to content

Programmers Direct

  • Posts

  • Joined

  • Last visited

Profile Information

  • Location
    Battle Creek, MI
  • Interests
    Working hard and designing code.
  • Activity

Recent Profile Visitors

5,392,548 profile views

Programmers Direct's Achievements


Newbie (1/14)




Community Answers

  1. Personally, I would just buy the module it cleans the categories all for you and you can set it up to do automatically too. https://addons.prestashop.com/en/administrative-tools/18334-auto-category-maintenance.html
  2. You can delete this as I cannot test or anything on this as I had no backups and for some reason when I cleared Prestashop cache it deleted all files on my server such as all php html and such files.
  3. I am pretty good at finding why things don't work but this even has me scratching my head. Can someone please point me in the right direction. I have looked over it and I cannot find what is wrong everything looks right. The issue is stated below with image. Maybe I am overlooking it or its a problem with the store configuration. In the ps_carriercompare module it does not populate states or updates to allow carrier selection.
  4. If you want to change the module and where it add the product you also have to change the attributes box and the page your one as well as adding js to allow it to update automatically and show the item on add look at how it is done in those pages and you can recreate it doing what you wish with examples to find.
  5. When things like this happens try deleting the prod folder in app\cache and it usually fixes these issues. However, it is not always a sure fix as every issue is unique to itself. Hope this helps.
  6. You must use the profiling tool to see what is taking so much time. For me it was the statistics modules in which I do not use as I use google analytics. Also enabling cache and other performance measures accompanied by a minimal layout design can get you down to 1-5 seconds for sure. I also believe that uninstalling modules that are not used is also beneficial as a disabled front office module still loads data and adds time to loading. I hope this helps, William
  7. Great article. But just in case you want an instant fix this module is available on the Prestashop Addons webite - http://addons.prestashop.com/en/18334-auto-category-maintenance.html We are working on making all our modules available on other carts as well so check out the Programmers Direct website.
  8. Make Checkboxes in Prestashop Using helpers I was working on a module and I noticed that there is a barrier to doing checkboxes in Prestashop using the helpers they provide. I did however, find some help through the watermark module created by Prestashop that uses checkboxes as directed by some on the Prestashop forum see it by clicking here -> https://www.prestashop.com/forums/topic/3516[spam-filter]show-helper-form-checkbox-checked/. Now it seemed quite complex and I believe this may become over cumbersome for those who do not develop regularly. so I decided to create this tutorial to help others in their developing endeavors. ***This tutorial assumes you already know how to create a form using the helpers and can add all the required information to build around the input array you see below. You can start by adding the check box input array below array( 'type' => 'checkbox', 'label' => $this->l('Options'), 'desc' => $this->l('Choose options to use during regeneration or generation of product references. The module processes like this-> (Reference will equal or be generated to be as follows with | separating each section of the custom inputs and the product based information.) Reference -> customidentifier|customsymbolpos1|(random number from 1-999)|customsymbolpos2|itemid|itemcategoryid|customsymbolpos3|itemsupplierid|customsymbolpos4|current reference only **NOT Supplier reference <---. Please leave custom fields blank if you want to not provide any custom identifiers or characters.'), 'name' => 'options', 'values' => array( 'query' => $this->getOptions(), 'id' => 'id_checkbox_options', 'name' => 'checkbox_options_name', 'expand' => array( 'print_total' => count($this->getOptions()), 'default' => 'show', 'show' => array('text' => $this->l('show'), 'icon' => 'plus-sign-alt'), 'hide' => array('text' => $this->l('hide'), 'icon' => 'minus-sign-alt') ), ), ), After that we need to create the query for the checkboxes available. public function getOptions() { $options = array ( array ( 'id_checkbox_options' => 0, 'checkbox_options_name' => 'Option 0'), array ( 'id_checkbox_options' => 1, 'checkbox_options_name' => 'Option 1'), array ( 'checkbox_options_options' => 2, 'checkbox_options_name' => 'Option 2'), array ( 'checkbox_options_options' => 3, 'checkbox_options_name' => 'Option 3'), array ( 'id_checkbox_options' => 4, 'checkbox_options_name' => 'option 4') ); return $options; } Now we get and save the information from checkboxes after posting or saving the form. private function _postProcess() { $output = ''; if (Tools::isSubmit('submitBtn')) { Configuration::updateValue('checkbox_text_demo', Tools::getValue('checkbox_text_demo')); $all_opts = $this->getOptions(); $checkbox_options = array(); foreach ($all_opts as $chbx_options) if (Tools::getValue('options_'.(int)$chbx_options['id_checkbox_options'])) $checkbox_options[] = $chbx_options['id_checkbox_options']; Configuration::updateValue('options', implode(',', $checkbox_options)); $output .= $this->displayConfirmation($this->l('Settings updated')); } } Lastly, we load the submitted information into checkboxes as we load the form along with other field variables. protected function getConfigFormValues() { $config_fields = array ( 'checkbox_text_demo' => Configuration::get('checkbox_text_demo'), // if you have other fields to fill this would fill text input field. ); //get all checkbox stuff all available $opts = $this->getOptions(); $id_checkbox_options = array(); foreach ($opts as $options) $id_checkbox_options[] = $options['id_checkbox_options']; //get checkbox stuff from $_POST $id_checkbox_options_post = array(); foreach ($id_checkbox_options as $opt_id) if (Tools::getValue('options_'.(int)$opt_id)) $id_checkbox_options_post['options_'.(int)$opt_id] = true; //get checkbox stuff from Configuration $id_checkbox_options_config = array(); if ($confs = Configuration::get('options')) $confs = explode(',', Configuration::get('options')); else $confs = array(); foreach ($confs as $conf) $id_checkbox_options_config['options_'.(int)$conf] = true; //return only common values and value from post if (Tools::isSubmit('submit_Btn')) $config_fields = array_merge($config_fields, array_intersect($id_checkbox_options_post, $id_checkbox_options_config)); else $config_fields = array_merge($config_fields, $id_checkbox_options_config); return $config_fields; } That's it!
  9. Okay I am working on a module and I have had the issue before, but generally it has always been some simple issue. However, this time I cannot find anything that would display a 1 on the index page as it is a column block module. It is a simple form that uses JQuery Ajax to perform the action, all of which works perfectly, but still displays a 1. I did try to debug but it seems i need to work on debugging skills as all I could gather is that the 1 had a data id of #text, which is nowhere in my code. It is for sure the module as the 1 is removed if the module is disabled or uninstalled. My questions to you all are; Have you had any issue with the displaying of a 1 in the front office? Have you had any issue like this with JQuery or Ajax? if yes to one or both, what was your resolution? All comments are appreciated sorry I cannot post the code, but was hoping some of the veteran Prestashop developers would have ran into this before with forms, jquery, ajax, or module and front office display that could help me out as I am just at a loss with it. SOLVED For reference when you set the header do not return true or it will show a 1 on the front office public function hookHeader() { $this->context->controller->addJquery(); $this->context->controller->addJS(($this->_path).'views/js/front.js'); $this->context->controller->addCSS(($this->_path).'views/css/front.css'); return true;// BAD DO NOT DO --- SHOWS A 1 ON SCREEN } As you can see the return true;// BAD DO NOT DO --- SHOWS A 1 ON SCREEN is a NO NO so do not do it.
  10. Yes that is very true, i thought that removing unused modules was mentioned sorry if I missed it. Yes deleting unused modules is a great idea as even if their disabled they are requeated when the website if used. I am very happy this helped all of you out. If there is any other things I can write an article about to help out further please give me some ideas and I will write and post them.
  • Create New...