SET NAMES 'utf8';

UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_CONDITIONS';
UPDATE `PREFIX_configuration` SET value = '12' WHERE name = 'PS_PRODUCTS_PER_PAGE';
UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_PRODUCTS_ORDER_WAY';
UPDATE `PREFIX_configuration` SET value = '4' WHERE name = 'PS_PRODUCTS_ORDER_BY';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DISPLAY_QTIES';
UPDATE `PREFIX_configuration` SET value = '20' WHERE name = 'PS_NB_DAYS_NEW_PRODUCT';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_BLOCK_CART_AJAX';
UPDATE `PREFIX_configuration` SET value = '8388608' WHERE name = 'PS_PRODUCT_PICTURE_MAX_SIZE';
UPDATE `PREFIX_configuration` SET value = '64' WHERE name = 'PS_PRODUCT_PICTURE_WIDTH';
UPDATE `PREFIX_configuration` SET value = '64' WHERE name = 'PS_PRODUCT_PICTURE_HEIGHT';
UPDATE `PREFIX_configuration` SET value = '3' WHERE name = 'PS_SEARCH_MINWORDLEN';
UPDATE `PREFIX_configuration` SET value = '6' WHERE name = 'PS_SEARCH_WEIGHT_PNAME';
UPDATE `PREFIX_configuration` SET value = '10' WHERE name = 'PS_SEARCH_WEIGHT_REF';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_SEARCH_WEIGHT_SHORTDESC';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_SEARCH_WEIGHT_DESC';
UPDATE `PREFIX_configuration` SET value = '3' WHERE name = 'PS_SEARCH_WEIGHT_CNAME';
UPDATE `PREFIX_configuration` SET value = '3' WHERE name = 'PS_SEARCH_WEIGHT_MNAME';
UPDATE `PREFIX_configuration` SET value = '4' WHERE name = 'PS_SEARCH_WEIGHT_TAG';
UPDATE `PREFIX_configuration` SET value = '2' WHERE name = 'PS_SEARCH_WEIGHT_ATTRIBUTE';
UPDATE `PREFIX_configuration` SET value = '2' WHERE name = 'PS_SEARCH_WEIGHT_FEATURE';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_SEARCH_AJAX';
UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_DISPLAY_JQZOOM';
UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_BLOCK_BESTSELLERS_DISPLAY';
UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_BLOCK_NEWPRODUCTS_DISPLAY';
UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_BLOCK_SPECIALS_DISPLAY';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_STORES_DISPLAY_CMS';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_STORES_DISPLAY_FOOTER';
UPDATE `PREFIX_configuration` SET value = '350' WHERE name = 'SHOP_LOGO_WIDTH';
UPDATE `PREFIX_configuration` SET value = '99' WHERE name = 'SHOP_LOGO_HEIGHT';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DISPLAY_SUPPLIERS';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DISPLAY_BEST_SELLERS';
UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'PS_LEGACY_IMAGES';
UPDATE `PREFIX_configuration` SET value = 'jpg' WHERE name = 'PS_IMAGE_QUALITY';
UPDATE `PREFIX_configuration` SET value = '7' WHERE name = 'PS_PNG_QUALITY';
UPDATE `PREFIX_configuration` SET value = '90' WHERE name = 'PS_JPEG_QUALITY';
UPDATE `PREFIX_configuration` SET value = '2' WHERE name = 'PRODUCTS_VIEWED_NBR';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'BLOCK_CATEG_DHTML';
UPDATE `PREFIX_configuration` SET value = '4' WHERE name = 'BLOCK_CATEG_MAX_DEPTH';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'MANUFACTURER_DISPLAY_FORM';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'MANUFACTURER_DISPLAY_TEXT';
UPDATE `PREFIX_configuration` SET value = '5' WHERE name = 'MANUFACTURER_DISPLAY_TEXT_NB';
UPDATE `PREFIX_configuration` SET value = '8' WHERE name = 'NEW_PRODUCTS_NBR';
UPDATE `PREFIX_configuration` SET value = '10' WHERE name = 'BLOCKTAGS_NBR';
UPDATE `PREFIX_configuration` SET value = '0_3|0_4' WHERE name = 'FOOTER_CMS';
UPDATE `PREFIX_configuration` SET value = '0_3|0_4' WHERE name = 'FOOTER_BLOCK_ACTIVATION';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'FOOTER_POWEREDBY';
UPDATE `PREFIX_configuration` SET value = 'http://www.ipresta.ir' WHERE name = 'BLOCKADVERT_LINK';
UPDATE `PREFIX_configuration` SET value = 'store.jpg' WHERE name = 'BLOCKSTORE_IMG';
UPDATE `PREFIX_configuration` SET value = 'jpg' WHERE name = 'BLOCKADVERT_IMG_EXT';
UPDATE `PREFIX_configuration` SET value = 'CAT3,CAT8,CAT5,LNK1' WHERE name = 'MOD_BLOCKTOPMENU_ITEMS';
UPDATE `PREFIX_configuration` SET value = '0' WHERE name = 'MOD_BLOCKTOPMENU_SEARCH';
UPDATE `PREFIX_configuration` SET value = 'http://www.facebook.com/persianpresta' WHERE name = 'BLOCKSOCIAL_FACEBOOK';
UPDATE `PREFIX_configuration` SET value = 'http://www.twitter.com/PrestaShopIran' WHERE name = 'BLOCKSOCIAL_TWITTER';
UPDATE `PREFIX_configuration` SET value = 'http://ipresta.ir/blog/' WHERE name = 'BLOCKSOCIAL_RSS';
UPDATE `PREFIX_configuration` SET value = 'https://www.google.com/+prestashop' WHERE name = 'BLOCKSOCIAL_GOOGLE_PLUS';
UPDATE `PREFIX_configuration` SET value = 'My Company' WHERE name = 'BLOCKCONTACTINFOS_COMPANY';
UPDATE `PREFIX_configuration` SET value = '42 Puffin street\n12345 Puffinville\nFrance' WHERE name = 'BLOCKCONTACTINFOS_ADDRESS';
UPDATE `PREFIX_configuration` SET value = '0123-456-789' WHERE name = 'BLOCKCONTACTINFOS_PHONE';
UPDATE `PREFIX_configuration` SET value = 'sales@yourcompany.com' WHERE name = 'BLOCKCONTACTINFOS_EMAIL';
UPDATE `PREFIX_configuration` SET value = '0123-456-789' WHERE name = 'BLOCKCONTACT_TELNUMBER';
UPDATE `PREFIX_configuration` SET value = 'sales@yourcompany.com' WHERE name = 'BLOCKCONTACT_EMAIL';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SUPPLIER_DISPLAY_TEXT';
UPDATE `PREFIX_configuration` SET value = '5' WHERE name = 'SUPPLIER_DISPLAY_TEXT_NB';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'SUPPLIER_DISPLAY_FORM';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'BLOCK_CATEG_NBR_COLUMN_FOOTER';
UPDATE `PREFIX_configuration` SET value = '' WHERE name = 'UPGRADER_BACKUPDB_FILENAME';
UPDATE `PREFIX_configuration` SET value = '' WHERE name = 'UPGRADER_BACKUPFILES_FILENAME';
UPDATE `PREFIX_configuration` SET value = '40' WHERE name = 'CONF_AVERAGE_PRODUCT_MARGIN';
UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DASHBOARD_SIMULATION';

/* No right column */
DELETE FROM `PREFIX_hook_module` WHERE id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayRightColumn');

/* displayHome */
SET @id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayHome');
UPDATE `PREFIX_hook_module` SET position = 1
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'themeconfigurator')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 3
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockcmsinfo')
AND id_hook = @id_hook;

/* displayNav */
SET @id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayNav');
UPDATE `PREFIX_hook_module` SET position = 1
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockuserinfo')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 2
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockcurrencies')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 3
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blocklanguages')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 4
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockcontact')
AND id_hook = @id_hook;

/* displayTop */
SET @id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayTop');
UPDATE `PREFIX_hook_module` SET position = 1
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blocksearch')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 2
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockcart')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 3
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blocktopmenu')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 4
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'themeconfigurator')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 5
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockwhislist')
AND id_hook = @id_hook;

/* displayHomeTab && displayHomeTabContent */
SET @id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayHomeTab');
SET @id_hook2 = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayHomeTabContent');

UPDATE `PREFIX_hook_module` SET position = 1
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blocknewproducts')
AND id_hook IN (@id_hook, @id_hook2);

UPDATE `PREFIX_hook_module` SET position = 2
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'homefeatured')
AND id_hook IN (@id_hook, @id_hook2);

UPDATE `PREFIX_hook_module` SET position = 3
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockbestsellers')
AND id_hook IN (@id_hook, @id_hook2);

/* displayFooter */
SET @id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayFooter');
UPDATE `PREFIX_hook_module` SET position = 1
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blocknewsletter')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 2
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blocksocial')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 3
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockcategories')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 4
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockcms')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 5
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockmyaccountfooter')
AND id_hook = @id_hook;

UPDATE `PREFIX_hook_module` SET position = 6
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockcontactinfos')
AND id_hook = @id_hook;

/* displayProductButtons */
SET @id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayProductButtons');
UPDATE `PREFIX_hook_module` SET position = 1
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'blockwishlist')
AND id_hook = @id_hook;
UPDATE `PREFIX_hook_module` SET position = 2
WHERE id_module = (SELECT id_module FROM `PREFIX_module` WHERE name = 'productpaymentlogos')
AND id_hook = @id_hook;

INSERT INTO `PREFIX_hook_module_exceptions` (`id_shop`, `id_module`, `id_hook`, `file_name`)
(
	SELECT 1, m.id_module, h.id_hook, 'category'
	FROM `PREFIX_hook` h
	JOIN `PREFIX_hook_module` hm ON (hm.id_hook = h.id_hook)
	JOIN `PREFIX_module` m ON (m.id_module = hm.id_module)
	WHERE
	h.name='displayLeftColumn' AND m.name IN ('blockbestsellers', 'blockmanufacturer', 'blocksupplier', 'blockmyaccount', 'blockpaymentlogo')
	GROUP BY m.id_module
);
