Jump to content

DevWL

New Members
  • Posts

    6
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

DevWL's Achievements

Newbie

Newbie (1/14)

  • First Post Rare
  • Week One Done Rare
  • One Month Later Rare
  • One Year In Rare

Recent Badges

1

Reputation

  1. Same problem here. First, make sure that you have no errors in your SQL scripts in: modules/yourmodulename/sql/install.php. modules/yourmodulename/upgrade/upgrade-x-x-x.php * in most cases this will be the problem. My problem was caused by removing the module manually. Basically I removed record from ps_module tabel manually and then removed the folder from modules catalog. Its seems that there is more references to this module in our database which might cause an issue. To investigate the issue check if you have any left over after non existing's module installation in your database table. SELECT ms.id_module as "ps_module_shop id_module" , m.id_module as "module id_module" FROM ps_module as m RIGHT JOIN ps_module_shop as ms ON m.id_module = ms.id_module WHERE m.id_module IS NULL; DELETE LAFTOVERS FROM ALL TABLES: DELETE FROM ps_module_shop WHERE id_module IN ( SELECT ms.id_module as "ms id" , m.id_module as "m id" FROM ps_module as m RIGHT JOIN ps_module_shop as ms ON m.id_module = ms.id_module WHERE m.id_module IS NULL; ); * The above sql will find all modules that does not exists in ps_module table but do exist in ps_module_shop table and removes them. -------------------------------------- Now go to ps_hook_module table and remove the record in similar way. So run: SELECT hm.id_module as "hm id" , m.id_module as "m id" FROM ps_module as m RIGHT JOIN ps_hook_module as hm ON m.id_module = hm.id_module WHERE m.id_module IS NULL; -- DELETE FROM ps_hook_module WHERE id_module IN (SELECT ...); --------------------------------------- We could do the same for ps_module_history table SELECT mh.id_module as "mh id" , m.id_module as "m id" FROM ps_module as m RIGHT JOIN ps_module_history as mh ON m.id_module = mh .id_module WHERE m.id_module IS NULL; -- DELETE FROM ps_module_history WHERE id_module IN (SELECT ...); --------------------------------------- NOTE - If you remove module manually and try to reinstall it you might need to do this: You should also see if there are any roles remained for you plugin name in ps_authorization_role table. My module name was "DEVWLH1" so this is what I search for. See the fallowing example: SELECT * FROM `ps_authorization_role` WHERE slug LIKE "%DEVWLH1%"; * Just make sure to replace LIKE ... with your actual module name "%yourmodulname%"; *IMPORTNT! - Make a note of the IDs you will return (write them down before deleting them - you will need to know them in another table); Then go to ps_module_access table and search for rows base on your previous findings from id_authorization_role table. Now you can delete them from ps_module_access table, and then do the same in ps_authorization_role table.
  2. You can also grup by years and months - this way you will not have to run this query for every month. This is quite simple to do. Consider the fallowing SQL: SELECT CONCAT(YEAR(o.invoice_date),' - ', MONTH(o.invoice_date)), substr(p.`reference`, 1, 3), COUNT(*) as `num_sales` FROM `ps_order_detail` od LEFT JOIN `ps_orders` o ON (od.`id_order` = o.`id_order`) LEFT JOIN `ps_product` p ON od.`product_id` = p.`id_product` WHERE o.`date_add` BETWEEN '2016-07-01' AND '2050-07-31' AND o.`id_order` NOT IN ( SELECT `id_order` FROM `ps_order_history` WHERE `id_order_state` = 6 ) GROUP BY CONCAT(YEAR(o.invoice_date),' - ', MONTH(o.invoice_date)), substr(p.`reference`, 1, 3)
  3. Lets update this topic for PrestaShop 1.7.7.5 with list of default modules (preinstalled). The query bellow will disable all non default PrestaShop modules. This might be useful if your PrestaShop is crashed and you need to disable all non core modules but you have no access to your admin dashboard. UPDATE ps_module SET active = 0 WHERE name NOT IN ('contactform', 'dashactivity', 'dashgoals', 'dashproducts', 'dashtrends', 'graphnvd3', 'gridhtml', 'gsitemap', 'pagesnotfound', 'productcomments', 'ps_banner', 'ps_categorytree', 'ps_checkpayment', 'ps_contactinfo', 'ps_crossselling', 'ps_currencyselector', 'ps_customeraccountlinks', 'ps_customersignin', 'ps_customtext', 'ps_dataprivacy', 'ps_emailsubscription', 'ps_faviconnotificationbo', 'ps_featuredproducts', 'ps_imageslider', 'ps_languageselector', 'ps_linklist', 'ps_mainmenu', 'ps_searchbar', 'ps_sharebuttons', 'ps_shoppingcart', 'ps_socialfollow', 'ps_themecusto', 'ps_wirepayment', 'sekeywords', 'statsbestcategories', 'statsbestcustomers', 'statsbestproducts', 'statsbestsuppliers', 'statsbestvouchers', 'statscarrier', 'statscatalog', 'statscheckup', 'statsdata', 'statsequipment', 'statsforecast', 'statslive', 'statsnewsletter', 'statsorigin', 'statspersonalinfos', 'statsproduct', 'statsregistrations', 'statssales', 'statssearch', 'statsstock', 'statsvisits', 'welcome', 'gamification', 'emarketing', 'psaddonsconnect', 'psgdpr', 'ps_mbo', 'ps_buybuttonlite', 'ps_metrics', 'ps_accounts', 'ps_eventbus', 'blockreassurance', 'ps_facetedsearch'); src: https://devwl.pl/disable-all-modules-in-prestashop-using-sql/
  4. Hi It would be very kind if someone provide a code example on how to use object to insert product in to database. Thanks!
  5. If you trying to move all products from one category to another, then you can try to use something like that /* * author: Wiktor Liszkiewicz * [email protected] * test at: https://paiza.io/projects/Rn1YBOVx4JkDo7YHu2xVtg?language=mysql * This scripts moves products from one category to another and also clenup the source category-product entry if the data is already asigned to destination category.. */ -- create table as in PrestaShop (clone) from https://github.com/PrestaShop/PrestaShop/blob/1.7.7.x/install-dev/data/db_structure.sql CREATE TABLE PREFIX_category_product ( id_category int(10) unsigned NOT NULL, id_product int(10) unsigned NOT NULL, position int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (id_category, id_product), INDEX (id_product), INDEX (id_category, position) ); -- insert demo data set I INSERT INTO PREFIX_category_product (id_category, id_product, position) VALUES (0, 5416, 1), (1, 5416, 1), (2, 5416, 1), (3, 5416, 1), (0, 5418, 2), (1, 5418, 2), (2, 5418, 2), (3, 5418, 2); -- insert demo data set II INSERT INTO PREFIX_category_product (id_category, id_product, position) VALUES (4, 2000, 1), (5, 2000, 1), (4, 5000, 2), (5, 5000, 2); -- check table data SELECT * FROM PREFIX_category_product; -- enter products id manualy or fint them wi query below -- define category SET @OLDCAT := 4; SET @NEWCAT := 0; -- set @STARTINGPOS position starting number will be 0 + 1 SET @STARTINGPOS := 0; -- or set @STARTINGPOS to the highest position value + 1 if category already have products select @STARTINGPOS := MAX(position) from PREFIX_category_product where id_category = @NEWCAT; -- select @STARTINGPOS; -- debug START TRANSACTION; -- start transation -- update category where id_product is in old category and is not in new category (cleen up later with DELETE query) UPDATE PREFIX_category_product SET id_category = @NEWCAT, position = (select @STARTINGPOS := @STARTINGPOS + 1) WHERE id_category = @OLDCAT AND id_product IN (SELECT * FROM (SELECT DISTINCT id_product FROM PREFIX_category_product WHERE id_category = @OLDCAT) AS t1) and id_product NOT IN (SELECT * FROM (SELECT DISTINCT id_product FROM PREFIX_category_product WHERE id_category = @NEWCAT) AS t2); -- remove products and category set if not moved because they are already assigned to destination category DELETE FROM PREFIX_category_product WHERE id_product IN (SELECT * FROM (SELECT DISTINCT id_product FROM PREFIX_category_product WHERE id_category = @OLDCAT) AS t3) AND id_category = @OLDCAT; COMMIT; -- end transation SELECT * FROM PREFIX_category_product; This would output the fallowing: The only thing you care about: Also make sure to change table prefi: to the one that you actually use (most likely it will be "ps_"). If you interested in running query on production then be sure to make a backup before attempting to do anything. FInd out your category sorce and destination ID and replace all "PREFIX_" in the query below with your own prefix (usually "ps_"). If you database is safe and you make everything ready then you can run the SQL query below. You could use phpMyAdmin or MySQL Workbench. SET @OLDCAT := 4; SET @NEWCAT := 0; -- set @STARTINGPOS position starting number will be 0 + 1 SET @STARTINGPOS := 0; -- or set @STARTINGPOS to the highest position value + 1 if category already have products select @STARTINGPOS := MAX(position) from PREFIX_category_product where id_category = @NEWCAT; -- select @STARTINGPOS; -- debug START TRANSACTION; -- start transation -- update category where id_product is in old category and is not in new category (cleen up later with DELETE query) UPDATE PREFIX_category_product SET id_category = @NEWCAT, position = (select @STARTINGPOS := @STARTINGPOS + 1) WHERE id_category = @OLDCAT AND id_product IN (SELECT * FROM (SELECT DISTINCT id_product FROM PREFIX_category_product WHERE id_category = @OLDCAT) AS t1) and id_product NOT IN (SELECT * FROM (SELECT DISTINCT id_product FROM PREFIX_category_product WHERE id_category = @NEWCAT) AS t2); -- remove products and category set if already moved or exsists in new category table DELETE FROM PREFIX_category_product WHERE id_product IN (SELECT * FROM (SELECT DISTINCT id_product FROM PREFIX_category_product WHERE id_category = @OLDCAT) AS t3) AND id_category = @OLDCAT; COMMIT; -- end transation
  6. This will happen if you remove demo invoice in your store without removing associated data for that orders. Solution is quite simple if you are familiar with MySQL and you are technical to some extend. No plugin is needed here. But if you are not ... do not touch it! You may brake your shop and no one will be able to fix that for you. Also don't get scared. Just do it the right way. So what you have to do ? Backup MySQL database is a must. Then save this data and make a copy of it. Do not edit the only file you have backuped! Edit the copy of your database with editor of your choice. Use Sublime Text if you ask me or VCode. Then search for demo_[1-9] This is a regular expression. Do not remove records where you will find demo_% - this is something else in different table. Doing the search above it should not come up, but just in case if you do search for demo_ and not demo_[1-9] jus dotnt touch it. You should find a MySQL Insert query starting with INSERT INTO v1_ps_order_detail Now remove all records containing demo_[1-9] with in them. Save the file Import database back to your server. If you get error with "Table name already exist" it means that you did not included DROP / CREATE statement to your backup file. This is not a problem. Remove all tabels from your database and import file again. If you did everything right then you have solved your issue.
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More