prestashop

Way to require an autoload in one file on a Prestashop module?

寵の児 提交于 2019-12-01 11:12:22
问题 I'm trying to use a set of libraries with Composer for a Prestashop module. My current approach is to include the vendor/autoload.php file on every file ( mymodule.php , controllers/front/foo.php , controllers/admin/bar.php , etc.) Doing the require only on top of the mymodule.php is not a solution, I don't see any hook to do the task. Is there a better approach than copy & paste the same snippet on top of every PHP file? Thank you! 回答1: I've found the way to do it! The actionDispatcher hook

addJS function not working for admin in prestashop

守給你的承諾、 提交于 2019-12-01 07:11:57
问题 I am trying to add javascript file in prestashop admin using backOfficeHeader hook using a module but nothing happened. My code is given below. public function install() { if (!parent::install() || !$this->registerHook('backOfficeHeader')) return false; return parent::install() && $this->registerHook('backOfficeHeader'); } public function hookBackOfficeHeader() { $this->context->controller->addJS(_MODULE_DIR_.$this->module->name.'js/hs_custom.js'); } 回答1: If you are using PS 1.5 or 1.6 you

Prestashop 1.6 get instance of module class

守給你的承諾、 提交于 2019-12-01 00:57:47
I have an overridden class OrderConfirmationControllerCore . I have a modul with class Abra . I need to get an instance of Abra class in the OrderConfirmationControllerCore My code is: class OrderConfirmationController extends OrderConfirmationControllerCore { public function init() { $abraSetDocs = new Abra(); parent::init(); } } This generates error: Fatal error: Class 'Abra' not found in /../override/controllers/front/OrderConfirmationController.php on line 39 How can I get the instance of the class? $abraSetDocs = Module::getInstanceByName('abra'); Note that 'abra' is the name of the

prestashop add images to products

时光总嘲笑我的痴心妄想 提交于 2019-11-30 17:10:08
问题 I have a product object, which I am creating in a PHP script. I need to add a thumbnail and a large image, which I have in a zip file. The file name contains the product ID. Whats the best way to achieve this in code? I'm assuming I need to extract the images to somewhere in file system, but I have no idea how prestashop handles images. thanks! 回答1: If you have the Product ID ($id_product) and the image URL ($url), you can do the following: $image = new Image(); $image->id_product = $id

Mac OS: Intl extension is not loaded

送分小仙女□ 提交于 2019-11-30 09:47:57
macOS Mojave 10.14.3 PHP 7.1.23 Prestashop 1.7.5.1 I tried to install PHP intl extension on my local server in order to use Prestashop. I added extension=php_intl.so to etc/php.ini When I try to install Prestashop I get Intl extension is not loaded . $ php -m | grep intl When I do $ php -m | grep intl , I get: PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20160303/php_intl.so' - d lopen(/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0 Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20160303

add a field in edit product page of prestashop admin

爷,独闯天下 提交于 2019-11-30 07:47:14
I have add a field "mystock" in product table of prestashop database. Now i want to display/edit this filed in edit product page. It also be update when product will update. This process require some work around in steps. Below i have listed them. 1) Open classes/Product.php. Place public $mystock; in the class properties list, which you can see after the class is started. 2) Down the file, find public static $definition = array( , it will be a long array. Find the 'fields' => array( in it, and there you will see all the database fields placed with validation, data types etc. Place your

Create product from a module in prestashop

孤人 提交于 2019-11-30 07:33:23
I guys i try to create a custom product from a module with this code : $defaultLanguage = new Language((int)(Configuration::get('PS_LANG_DEFAULT'))); /* Add a new product */ $object = new Product(); $object->price = 22; $object->id_tax_rules_group = 0; $object->name = 'test'; $object->id_manufacturer = 0; $object->id_supplier = 0; $object->quantity = 1; $object->minimal_quantity = 1; $object->additional_shipping_cost = 0; $object->wholesale_price = 0; $object->ecotax = 0; $object->width = 0; $object->height = 0; $object->depth = 0; $object->weight = 0; $object->out_of_stock = 0; $object-

Access Prestashop webservice from JavaScript

点点圈 提交于 2019-11-30 05:29:07
In the Prestashop backend I activated the webservice and I created an authentication key. Testing in browser works well but now I want to access the webservice via JavaScript in a Cordova application. The response I am getting is 401 (Unauthorized) . I'm performing this ajax call (using AngularJS): $http.get('http://AUTHENTICATION_KEY@url.com/api/employees/2', {}) How do I have to send the authentication key? I've been searching on the Internet but I did not found anything interesting that solves my problem. Finally, I figured out how to send the ws_key: $http({ method: 'get', url: ws_url +

Facebook Like Button Causing Horizontal Scrollbar

余生长醉 提交于 2019-11-30 04:24:52
问题 I've recently added a facebook like button to my site and it's causing a horizontal scrollbar to appear when it's not needed. It doesn't appear in Chrome but is there in Firefox and IE. I've checked the created code in Firebug and can't see what's going wrong. Here's a link to the site so you can see: http://www.swiftfurniture.com/ As you can see, on Firefox and IE (possibly other browsers too), there's a horizontal scrollbar when it isn't needed. It's definitely the Facebook like button

TypeError: $(…).owlCarousel is not a function

时光毁灭记忆、已成空白 提交于 2019-11-29 13:59:44
I am having troubles adding this carousel to my prestashop template. It returns me the following error: TypeError: $(...).owlCarousel is not a function navigation : true And the code using to initialize it is this one $(document).ready(function() { $("#owl-demo").owlCarousel({ navigation : true }); }); I am trying to solve it, but seems imposible, since on an empty html page it works but not when I use it on the Prestashop. Any clue? Thanks. Manoj Verma Add owl.carousel.min.js file in your home page and before the file in which you are using add the following code: $("#owl-demo").owlCarousel({