keithg

Create Url (short url) in prestashop 1. 7

With Module you can make a link in tpl. spstepcheckout is the module name ane ajax is front controller . old way : {$link->getModuleLink(‘spstepcheckout’,’ajax’)} new way : {url entity=’module’ name=’spstepcheckout’ controller=’ajax’ params=[‘edited’ => 1, ‘id’ => $id]} Without Module make a controller link. cart is the controller name and pass parameter...Read more …
keithg

add to cart in ajax in prestashop 1.7

javascript var pid = $(‘#product_id’).val(); $.ajax({ url : url+’&action=savecustomdataAction’, type : “POST”, data : { customdata : customdata, qty : 1, pid : pid }, success : function(response) { if(response.message == true) { $(‘#addtocart_form’).submit(); } } });   Tpl file <script> var url =”{url entity=’module’ name=’appcustomizer’ controller=’ajaxfunc’ params = []}”;...Read more …
keithg

Use namespace in module when you want to display products.

use PrestaShop\PrestaShop\Adapter\Category\CategoryProductSearchProvider; use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever; use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter; use PrestaShop\PrestaShop\Core\Product\ProductListingPresenter; use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever; use PrestaShop\PrestaShop\Adapter\Translator; use PrestaShop\PrestaShop\Adapter\LegacyContext; use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; use PrestaShop\PrestaShop\Core\Product\Search\SortOrder; //Code to get the products $RESULTS == From query results $blocks_for_template = []; $products_for_template = []; $assembler = new ProductAssembler($this->context); $presenterFactory = new ProductPresenterFactory($this->context); $presentationSettings = $presenterFactory->getPresentationSettings(); $presenter = new...Read more …
keithg

Prestashop Important Point

Add CSS in controller. if (version_compare(_PS_VERSION_, ‘1.6.0’, ‘<‘)) { $this->context->controller->addCSS($this->module->getPathURI().’/views/css/admin15.css’); } //  loaded css and js in module controller public function setMedia() { parent::setMedia(); $this->context->controller->registerStylesheet(‘affiliatestyle-css’,’modules/’.$this->module->name.’/css/affiliatestyle.css’,[‘media’ => ‘all’, ‘priority’ => 0]); $this->context->controller->registerJavascript(‘sendtoafriend-js’,modules/’.$this->module->name.’/’sendtoafriend.js’,[‘position’ => ‘bottom’, ‘priority’ => 0]); } add css and js in a Header or footer hook $this->context->controller->registerJavascript(‘sendtoafriend-js’,$this->_path.’/css/js/sendtoafriend.js’,[‘position’ => ‘bottom’,...Read more …
keithg

renderForm – Prestashop

public function renderForm() { $this->fields_form = array( ‘tinymce’ => false, ‘legend’ => array( ‘title’ => $this->l(‘Product label’), ‘icon’ => ‘icon-tags’ ), ‘input’ => array( array( ‘type’ => ((float)_PS_VERSION_ < 1.6 ? ‘radio’ : ‘switch’), ‘label’ => $this->l(‘Enabled’), ‘name’ => ‘active’, ‘class’ => ‘t’, ‘required’ => false, ‘is_bool’ => true, ‘values’...Read more …