diff --git a/cache/class_index.php b/cache/class_index.php
index 5bd3d5be3..4d1d4516d 100644
--- a/cache/class_index.php
+++ b/cache/class_index.php
@@ -1,10 +1,10 @@
'classes/AbstractLogger.php',
'AbstractLogger' => 'override/classes/AbstractLogger.php',
- 'AddressCore' => 'classes/Address.php',
- 'Address' => 'override/classes/Address.php',
'AddressFormatCore' => 'classes/AddressFormat.php',
'AddressFormat' => 'override/classes/AddressFormat.php',
+ 'AddressCore' => 'classes/Address.php',
+ 'Address' => 'override/classes/Address.php',
'AdminControllerCore' => 'classes/AdminController.php',
'AdminController' => 'override/classes/AdminController.php',
'AdminTabCore' => 'classes/AdminTab.php',
@@ -13,29 +13,39 @@
'Alias' => 'override/classes/Alias.php',
'AttachmentCore' => 'classes/Attachment.php',
'Attachment' => 'override/classes/Attachment.php',
- 'AttributeCore' => 'classes/Attribute.php',
- 'Attribute' => 'override/classes/Attribute.php',
'AttributeGroupCore' => 'classes/AttributeGroup.php',
'AttributeGroup' => 'override/classes/AttributeGroup.php',
+ 'AttributeCore' => 'classes/Attribute.php',
+ 'Attribute' => 'override/classes/Attribute.php',
'Autoload' => 'classes/Autoload.php',
'BackupCore' => 'classes/Backup.php',
'Backup' => 'override/classes/Backup.php',
'BlowfishCore' => 'classes/Blowfish.php',
'Blowfish' => 'override/classes/Blowfish.php',
- 'CMSCore' => 'classes/CMS.php',
- 'CMS' => 'override/classes/CMS.php',
- 'CMSCategoryCore' => 'classes/CMSCategory.php',
- 'CMSCategory' => 'override/classes/CMSCategory.php',
- 'CarrierCore' => 'classes/Carrier.php',
- 'Carrier' => 'override/classes/Carrier.php',
+ 'CacheApcCore' => 'classes/cache/CacheApc.php',
+ 'CacheApc' => 'override/classes/cache/CacheApc.php',
+ 'CacheFsCore' => 'classes/cache/CacheFs.php',
+ 'CacheFs' => 'override/classes/cache/CacheFs.php',
+ 'CacheMemcacheCore' => 'classes/cache/CacheMemcache.php',
+ 'CacheMemcache' => 'override/classes/cache/CacheMemcache.php',
+ 'CacheCore' => 'classes/cache/Cache.php',
+ 'Cache' => 'override/classes/cache/Cache.php',
+ 'CacheXcacheCore' => 'classes/cache/CacheXcache.php',
+ 'CacheXcache' => 'override/classes/cache/CacheXcache.php',
'CarrierModuleCore' => 'classes/CarrierModule.php',
'CarrierModule' => 'override/classes/CarrierModule.php',
+ 'CarrierCore' => 'classes/Carrier.php',
+ 'Carrier' => 'override/classes/Carrier.php',
'CartCore' => 'classes/Cart.php',
'Cart' => 'override/classes/Cart.php',
'CategoryCore' => 'classes/Category.php',
'Category' => 'override/classes/Category.php',
'ChartCore' => 'classes/Chart.php',
'Chart' => 'override/classes/Chart.php',
+ 'CMSCategoryCore' => 'classes/CMSCategory.php',
+ 'CMSCategory' => 'override/classes/CMSCategory.php',
+ 'CMSCore' => 'classes/CMS.php',
+ 'CMS' => 'override/classes/CMS.php',
'CombinationCore' => 'classes/Combination.php',
'Combination' => 'override/classes/Combination.php',
'CompareProductCore' => 'classes/CompareProduct.php',
@@ -52,10 +62,10 @@
'Contact' => 'override/classes/Contact.php',
'ContextCore' => 'classes/Context.php',
'Context' => 'override/classes/Context.php',
- 'ControllerCore' => 'classes/Controller.php',
- 'Controller' => 'override/classes/Controller.php',
'ControllerFactoryCore' => 'classes/ControllerFactory.php',
'ControllerFactory' => 'override/classes/ControllerFactory.php',
+ 'ControllerCore' => 'classes/Controller.php',
+ 'Controller' => 'override/classes/Controller.php',
'CookieCore' => 'classes/Cookie.php',
'Cookie' => 'override/classes/Cookie.php',
'CountryCore' => 'classes/Country.php',
@@ -64,16 +74,26 @@
'County' => 'override/classes/County.php',
'CurrencyCore' => 'classes/Currency.php',
'Currency' => 'override/classes/Currency.php',
- 'CustomerCore' => 'classes/Customer.php',
- 'Customer' => 'override/classes/Customer.php',
'CustomerMessageCore' => 'classes/CustomerMessage.php',
'CustomerMessage' => 'override/classes/CustomerMessage.php',
+ 'CustomerCore' => 'classes/Customer.php',
+ 'Customer' => 'override/classes/Customer.php',
'CustomerThreadCore' => 'classes/CustomerThread.php',
'CustomerThread' => 'override/classes/CustomerThread.php',
'CustomizationCore' => 'classes/Customization.php',
'Customization' => 'override/classes/Customization.php',
'DateRangeCore' => 'classes/DateRange.php',
'DateRange' => 'override/classes/DateRange.php',
+ 'DbMySQLiCore' => 'classes/db/DbMySQLi.php',
+ 'DbMySQLi' => 'override/classes/db/DbMySQLi.php',
+ 'DbPDOCore' => 'classes/db/DbPDO.php',
+ 'DbPDO' => 'override/classes/db/DbPDO.php',
+ 'DbCore' => 'classes/db/Db.php',
+ 'Db' => 'override/classes/db/Db.php',
+ 'DbQueryCore' => 'classes/db/DbQuery.php',
+ 'DbQuery' => 'override/classes/db/DbQuery.php',
+ 'MySQLCore' => 'classes/db/MySQL.php',
+ 'MySQL' => 'override/classes/db/MySQL.php',
'DeliveryCore' => 'classes/Delivery.php',
'Delivery' => 'override/classes/Delivery.php',
'DiscountCore' => 'classes/Discount.php',
@@ -82,6 +102,14 @@
'Dispatcher' => 'override/classes/Dispatcher.php',
'EmployeeCore' => 'classes/Employee.php',
'Employee' => 'override/classes/Employee.php',
+ 'PrestashopDatabaseExceptionCore' => 'classes/exception/PrestashopDatabaseException.php',
+ 'PrestashopDatabaseException' => 'override/classes/exception/PrestashopDatabaseException.php',
+ 'PrestashopExceptionCore' => 'classes/exception/PrestashopException.php',
+ 'PrestashopException' => 'override/classes/exception/PrestashopException.php',
+ 'PrestashopModuleExceptionCore' => 'classes/exception/PrestashopModuleException.php',
+ 'PrestashopModuleException' => 'override/classes/exception/PrestashopModuleException.php',
+ 'PrestashopPaymentExceptionCore' => 'classes/exception/PrestashopPaymentException.php',
+ 'PrestashopPaymentException' => 'override/classes/exception/PrestashopPaymentException.php',
'FeatureCore' => 'classes/Feature.php',
'Feature' => 'override/classes/Feature.php',
'FeatureValueCore' => 'classes/FeatureValue.php',
@@ -102,14 +130,14 @@
'Guest' => 'override/classes/Guest.php',
'HelpAccessCore' => 'classes/HelpAccess.php',
'HelpAccess' => 'override/classes/HelpAccess.php',
- 'HelperCore' => 'classes/Helper.php',
- 'Helper' => 'override/classes/Helper.php',
'HelperFormCore' => 'classes/HelperForm.php',
'HelperForm' => '',
'HelperListCore' => 'classes/HelperList.php',
'HelperList' => '',
'HelperOptionsCore' => 'classes/HelperOptions.php',
'HelperOptions' => '',
+ 'HelperCore' => 'classes/Helper.php',
+ 'Helper' => 'override/classes/Helper.php',
'HookCore' => 'classes/Hook.php',
'Hook' => 'override/classes/Hook.php',
'ImageCore' => 'classes/Image.php',
@@ -136,22 +164,20 @@
'Message' => 'override/classes/Message.php',
'MetaCore' => 'classes/Meta.php',
'Meta' => 'override/classes/Meta.php',
- 'ModuleCore' => 'classes/Module.php',
- 'Module' => 'override/classes/Module.php',
- 'ModuleGraphCore' => 'classes/ModuleGraph.php',
- 'ModuleGraph' => 'override/classes/ModuleGraph.php',
'ModuleGraphEngineCore' => 'classes/ModuleGraphEngine.php',
'ModuleGraphEngine' => 'override/classes/ModuleGraphEngine.php',
- 'ModuleGridCore' => 'classes/ModuleGrid.php',
- 'ModuleGrid' => 'override/classes/ModuleGrid.php',
+ 'ModuleGraphCore' => 'classes/ModuleGraph.php',
+ 'ModuleGraph' => 'override/classes/ModuleGraph.php',
'ModuleGridEngineCore' => 'classes/ModuleGridEngine.php',
'ModuleGridEngine' => 'override/classes/ModuleGridEngine.php',
+ 'ModuleGridCore' => 'classes/ModuleGrid.php',
+ 'ModuleGrid' => 'override/classes/ModuleGrid.php',
+ 'ModuleCore' => 'classes/Module.php',
+ 'Module' => 'override/classes/Module.php',
'NotificationCore' => 'classes/Notification.php',
'Notification' => 'override/classes/Notification.php',
'ObjectModelCore' => 'classes/ObjectModel.php',
'ObjectModel' => 'override/classes/ObjectModel.php',
- 'OrderCore' => 'classes/Order.php',
- 'Order' => 'override/classes/Order.php',
'OrderDetailCore' => 'classes/OrderDetail.php',
'OrderDetail' => 'override/classes/OrderDetail.php',
'OrderDiscountCore' => 'classes/OrderDiscount.php',
@@ -160,6 +186,8 @@
'OrderHistory' => 'override/classes/OrderHistory.php',
'OrderMessageCore' => 'classes/OrderMessage.php',
'OrderMessage' => 'override/classes/OrderMessage.php',
+ 'OrderCore' => 'classes/Order.php',
+ 'Order' => 'override/classes/Order.php',
'OrderReturnCore' => 'classes/OrderReturn.php',
'OrderReturn' => 'override/classes/OrderReturn.php',
'OrderReturnStateCore' => 'classes/OrderReturnState.php',
@@ -168,8 +196,6 @@
'OrderSlip' => 'override/classes/OrderSlip.php',
'OrderStateCore' => 'classes/OrderState.php',
'OrderState' => 'override/classes/OrderState.php',
- 'PDFCore' => 'classes/PDF.php',
- 'PDF' => 'override/classes/PDF.php',
'PackCore' => 'classes/Pack.php',
'Pack' => 'override/classes/Pack.php',
'PageCore' => 'classes/Page.php',
@@ -178,10 +204,12 @@
'PaymentCC' => 'override/classes/PaymentCC.php',
'PaymentModuleCore' => 'classes/PaymentModule.php',
'PaymentModule' => 'override/classes/PaymentModule.php',
- 'ProductCore' => 'classes/Product.php',
- 'Product' => 'override/classes/Product.php',
+ 'PDFCore' => 'classes/PDF.php',
+ 'PDF' => 'override/classes/PDF.php',
'ProductDownloadCore' => 'classes/ProductDownload.php',
'ProductDownload' => 'override/classes/ProductDownload.php',
+ 'ProductCore' => 'classes/Product.php',
+ 'Product' => 'override/classes/Product.php',
'ProductSaleCore' => 'classes/ProductSale.php',
'ProductSale' => 'override/classes/ProductSale.php',
'ProfileCore' => 'classes/Profile.php',
@@ -200,14 +228,36 @@
'Rijndael' => 'override/classes/Rijndael.php',
'SceneCore' => 'classes/Scene.php',
'Scene' => 'override/classes/Scene.php',
- 'SearchCore' => 'classes/Search.php',
- 'Search' => 'override/classes/Search.php',
'SearchEngineCore' => 'classes/SearchEngine.php',
'SearchEngine' => 'override/classes/SearchEngine.php',
+ 'SearchCore' => 'classes/Search.php',
+ 'Search' => 'override/classes/Search.php',
+ 'GroupShopCore' => 'classes/shop/GroupShop.php',
+ 'GroupShop' => 'override/classes/shop/GroupShop.php',
+ 'ShopCore' => 'classes/shop/Shop.php',
+ 'Shop' => 'override/classes/shop/Shop.php',
+ 'ShopUrlCore' => 'classes/shop/ShopUrl.php',
+ 'ShopUrl' => 'override/classes/shop/ShopUrl.php',
'SpecificPriceCore' => 'classes/SpecificPrice.php',
'SpecificPrice' => 'override/classes/SpecificPrice.php',
'StateCore' => 'classes/State.php',
'State' => 'override/classes/State.php',
+ 'StockAvailableCore' => 'classes/stock/StockAvailable.php',
+ 'StockAvailable' => '',
+ 'StockManagerFactoryCore' => 'classes/stock/StockManagerFactory.php',
+ 'StockManagerFactory' => '',
+ 'StockManagerInterface' => 'classes/stock/StockManagerInterface.php',
+ 'StockManagerModule' => 'classes/stock/StockManagerModule.php',
+ 'StockManagerCore' => 'classes/stock/StockManager.php',
+ 'StockManager' => '',
+ 'StockMvtCore' => 'classes/stock/StockMvt.php',
+ 'StockMvt' => 'override/classes/StockMvt.php',
+ 'StockMvtReasonCore' => 'classes/stock/StockMvtReason.php',
+ 'StockMvtReason' => 'override/classes/StockMvtReason.php',
+ 'StockCore' => 'classes/stock/Stock.php',
+ 'Stock' => 'override/classes/Stock.php',
+ 'WarehouseCore' => 'classes/stock/Warehouse.php',
+ 'Warehouse' => '',
'StoreCore' => 'classes/Store.php',
'Store' => 'override/classes/Store.php',
'SubDomainCore' => 'classes/SubDomain.php',
@@ -218,6 +268,21 @@
'Tab' => 'override/classes/Tab.php',
'TagCore' => 'classes/Tag.php',
'Tag' => 'override/classes/Tag.php',
+ 'TaxCalculatorCore' => 'classes/tax/TaxCalculator.php',
+ 'TaxCalculator' => 'override/classes/tax/TaxCalculator.php',
+ 'TaxManagerFactoryCore' => 'classes/tax/TaxManagerFactory.php',
+ 'TaxManagerFactory' => 'override/classes/tax/TaxManagerFactory.php',
+ 'TaxManagerInterface' => 'classes/tax/TaxManagerInterface.php',
+ 'TaxManagerModuleCore' => 'classes/tax/TaxManagerModule.php',
+ 'TaxManagerModule' => 'override/classes/tax/TaxManagerModule.php',
+ 'TaxCore' => 'classes/tax/Tax.php',
+ 'Tax' => 'override/classes/tax/Tax.php',
+ 'TaxRuleCore' => 'classes/tax/TaxRule.php',
+ 'TaxRule' => 'override/classes/tax/TaxRule.php',
+ 'TaxRulesGroupCore' => 'classes/tax/TaxRulesGroup.php',
+ 'TaxRulesGroup' => 'override/classes/tax/TaxRulesGroup.php',
+ 'TaxRulesTaxManagerCore' => 'classes/tax/TaxRulesTaxManager.php',
+ 'TaxRulesTaxManager' => 'override/classes/tax/TaxRulesTaxManager.php',
'ThemeCore' => 'classes/Theme.php',
'Theme' => 'override/classes/Theme.php',
'ToolsCore' => 'classes/Tools.php',
@@ -228,73 +293,6 @@
'Upgrader' => 'override/classes/Upgrader.php',
'ValidateCore' => 'classes/Validate.php',
'Validate' => 'override/classes/Validate.php',
- 'ZoneCore' => 'classes/Zone.php',
- 'Zone' => 'override/classes/Zone.php',
- 'CacheCore' => 'classes/cache/Cache.php',
- 'Cache' => 'override/classes/cache/Cache.php',
- 'CacheApcCore' => 'classes/cache/CacheApc.php',
- 'CacheApc' => 'override/classes/cache/CacheApc.php',
- 'CacheFsCore' => 'classes/cache/CacheFs.php',
- 'CacheFs' => 'override/classes/cache/CacheFs.php',
- 'CacheMemcacheCore' => 'classes/cache/CacheMemcache.php',
- 'CacheMemcache' => 'override/classes/cache/CacheMemcache.php',
- 'CacheXcacheCore' => 'classes/cache/CacheXcache.php',
- 'CacheXcache' => 'override/classes/cache/CacheXcache.php',
- 'DbCore' => 'classes/db/Db.php',
- 'Db' => 'override/classes/db/Db.php',
- 'DbMySQLiCore' => 'classes/db/DbMySQLi.php',
- 'DbMySQLi' => 'override/classes/db/DbMySQLi.php',
- 'DbPDOCore' => 'classes/db/DbPDO.php',
- 'DbPDO' => 'override/classes/db/DbPDO.php',
- 'DbQueryCore' => 'classes/db/DbQuery.php',
- 'DbQuery' => 'override/classes/db/DbQuery.php',
- 'MySQLCore' => 'classes/db/MySQL.php',
- 'MySQL' => 'override/classes/db/MySQL.php',
- 'PrestashopDatabaseExceptionCore' => 'classes/exception/PrestashopDatabaseException.php',
- 'PrestashopDatabaseException' => 'override/classes/exception/PrestashopDatabaseException.php',
- 'PrestashopExceptionCore' => 'classes/exception/PrestashopException.php',
- 'PrestashopException' => 'override/classes/exception/PrestashopException.php',
- 'PrestashopModuleExceptionCore' => 'classes/exception/PrestashopModuleException.php',
- 'PrestashopModuleException' => 'override/classes/exception/PrestashopModuleException.php',
- 'PrestashopPaymentExceptionCore' => 'classes/exception/PrestashopPaymentException.php',
- 'PrestashopPaymentException' => 'override/classes/exception/PrestashopPaymentException.php',
- 'GroupShopCore' => 'classes/shop/GroupShop.php',
- 'GroupShop' => 'override/classes/shop/GroupShop.php',
- 'ShopCore' => 'classes/shop/Shop.php',
- 'Shop' => 'override/classes/shop/Shop.php',
- 'ShopUrlCore' => 'classes/shop/ShopUrl.php',
- 'ShopUrl' => 'override/classes/shop/ShopUrl.php',
- 'StockCore' => 'classes/stock/Stock.php',
- 'Stock' => 'override/classes/Stock.php',
- 'StockAvailableCore' => 'classes/stock/StockAvailable.php',
- 'StockAvailable' => '',
- 'StockManagerCore' => 'classes/stock/StockManager.php',
- 'StockManager' => '',
- 'StockManagerFactoryCore' => 'classes/stock/StockManagerFactory.php',
- 'StockManagerFactory' => '',
- 'StockManagerInterface' => 'classes/stock/StockManagerInterface.php',
- 'StockManagerModule' => 'classes/stock/StockManagerModule.php',
- 'StockMvtCore' => 'classes/stock/StockMvt.php',
- 'StockMvt' => 'override/classes/StockMvt.php',
- 'StockMvtReasonCore' => 'classes/stock/StockMvtReason.php',
- 'StockMvtReason' => 'override/classes/StockMvtReason.php',
- 'WarehouseCore' => 'classes/stock/Warehouse.php',
- 'Warehouse' => '',
- 'TaxCore' => 'classes/tax/Tax.php',
- 'Tax' => 'override/classes/tax/Tax.php',
- 'TaxCalculatorCore' => 'classes/tax/TaxCalculator.php',
- 'TaxCalculator' => 'override/classes/tax/TaxCalculator.php',
- 'TaxManagerFactoryCore' => 'classes/tax/TaxManagerFactory.php',
- 'TaxManagerFactory' => 'override/classes/tax/TaxManagerFactory.php',
- 'TaxManagerInterface' => 'classes/tax/TaxManagerInterface.php',
- 'TaxManagerModuleCore' => 'classes/tax/TaxManagerModule.php',
- 'TaxManagerModule' => 'override/classes/tax/TaxManagerModule.php',
- 'TaxRuleCore' => 'classes/tax/TaxRule.php',
- 'TaxRule' => 'override/classes/tax/TaxRule.php',
- 'TaxRulesGroupCore' => 'classes/tax/TaxRulesGroup.php',
- 'TaxRulesGroup' => 'override/classes/tax/TaxRulesGroup.php',
- 'TaxRulesTaxManagerCore' => 'classes/tax/TaxRulesTaxManager.php',
- 'TaxRulesTaxManager' => 'override/classes/tax/TaxRulesTaxManager.php',
'WebserviceExceptionCore' => 'classes/webservice/WebserviceException.php',
'WebserviceException' => 'override/classes/webservice/WebserviceException.php',
'WebserviceKeyCore' => 'classes/webservice/WebserviceKey.php',
@@ -311,11 +309,15 @@
'WebserviceSpecificManagementInterface' => 'classes/webservice/WebserviceSpecificManagementInterface.php',
'WebserviceSpecificManagementSearchCore' => 'classes/webservice/WebserviceSpecificManagementSearch.php',
'WebserviceSpecificManagementSearch' => 'override/classes/webservice/WebserviceSpecificManagementSearch.php',
+ 'ZoneCore' => 'classes/Zone.php',
+ 'Zone' => 'override/classes/Zone.php',
'FB' => 'override/classes/fb.php',
'AdminAddressesControllerCore' => 'controllers/admin/AdminAddressesController.php',
'AdminAddressesController' => '',
'AdminAliasesControllerCore' => 'controllers/admin/AdminAliasesController.php',
'AdminAliasesController' => '',
+ 'AdminBackupControllerCore' => 'controllers/admin/AdminBackupController.php',
+ 'AdminBackupController' => '',
'AdminGendersController' => 'controllers/admin/AdminGendersController.php',
'AdminGroupShopControllerCore' => 'controllers/admin/AdminGroupShopController.php',
'AdminGroupShopController' => '',
@@ -334,9 +336,15 @@
'AdminStatesController' => '',
'AdminStockControllerCore' => 'controllers/admin/AdminStockController.php',
'AdminStockController' => '',
+ 'AdminStockInstantStateControllerCore' => 'controllers/admin/AdminStockInstantStateController.php',
+ 'AdminStockInstantStateController' => '',
+ 'AdminStoresControllerCore' => 'controllers/admin/AdminStoresController.php',
+ 'AdminStoresController' => '',
'AdminToolsControllerCore' => 'controllers/admin/AdminToolsController.php',
'AdminToolsController' => 'override/controllers/admin/AdminToolsController.php',
'AdminTrackingController' => 'controllers/admin/AdminTrackingController.php',
+ 'AdminWarehousesControllerCore' => 'controllers/admin/AdminWarehousesController.php',
+ 'AdminWarehousesController' => '',
'AddressControllerCore' => 'controllers/front/AddressController.php',
'AddressController' => 'override/controllers/front/AddressController.php',
'AddressesControllerCore' => 'controllers/front/AddressesController.php',
diff --git a/classes/Product.php b/classes/Product.php
index 3ee4a217e..fb7f3c302 100644
--- a/classes/Product.php
+++ b/classes/Product.php
@@ -3615,5 +3615,48 @@ class ProductCore extends ObjectModel
FROM `'._DB_PREFIX_.'product_attribute`
WHERE `id_product` = '.(int)$id_product);
}
+
+ /**
+ * Get label by lang and value by lang too
+ * @param int $id_product
+ * @param int $product_attribute_id
+ */
+ public static function getAttributesParams($id_product, $id_product_attribute)
+ {
+ return Db::getInstance()->executeS('
+ SELECT al.`name`, agl.`name` as `group`
+ FROM `'._DB_PREFIX_.'attribute` a
+ LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
+ ON (al.`id_attribute` = a.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
+ LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
+ ON (pac.`id_attribute` = a.`id_attribute`)
+ LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
+ ON (pa.`id_product_attribute` = pac.`id_product_attribute`)
+ LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
+ ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
+ WHERE pa.`id_product` = '.(int)$id_product.'
+ AND pac.`id_product_attribute` = '.(int)$id_product_attribute.'
+ AND agl.`id_lang` = '.(int)Context::getContext()->language->id);
+ }
+
+ /**
+ * @param int $id_product
+ */
+ public static function getAttributesInformationsByProduct($id_product)
+ {
+ return Db::getInstance()->executeS('
+ SELECT DISTINCT a.`id_attribute`, a.`id_attribute_group`, al.`name` as `attribute`, agl.`name` as `group`
+ FROM `'._DB_PREFIX_.'attribute` a
+ LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
+ ON (a.`id_attribute` = al.`id_attribute` AND al.`id_lang` = '.(int)Context::getContext()->language->id.')
+ LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
+ ON (a.`id_attribute_group` = agl.`id_attribute_group` AND agl.`id_lang` = '.(int)Context::getContext()->language->id.')
+ LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac
+ ON (a.`id_attribute` = pac.`id_attribute`)
+ LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa
+ ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
+ WHERE pa.`id_product` = '.(int)$id_product);
+ }
+
}
diff --git a/controllers/front/ProductController.php b/controllers/front/ProductController.php
index 977f84dda..d2c8fdf74 100644
--- a/controllers/front/ProductController.php
+++ b/controllers/front/ProductController.php
@@ -42,12 +42,10 @@ class ProductControllerCore extends FrontController
);
if (Configuration::get('PS_DISPLAY_JQZOOM') == 1)
- {
$this->addJqueryPlugin('jqzoom');
- }
}
- public function canonicalRedirection($canonicalURL = '')
+ public function canonicalRedirection($canonical_url = '')
{
if (Validate::isLoadedObject($this->product))
parent::canonicalRedirection($this->context->link->getProductLink($this->product));
@@ -99,6 +97,23 @@ class ProductControllerCore extends FrontController
}
}
+ public function ajaxProcess()
+ {
+ if (Tools::getValue('getAttributesParams'))
+ {
+ $product_id = Tools::getValue('id_product');
+ $ipa = Tools::getValue('ipa');
+ $tab_params = Product::getAttributesParams($product_id, $ipa);
+ foreach ($tab_params as &$param)
+ $param = array_map('Tools::str2url', $param);
+ die(Tools::jsonEncode($tab_params));
+ }
+ if (Tools::getValue('couleur'))
+ {
+ d('cc');
+ }
+ }
+
/**
* Assign template vars related to page content
* @see FrontController::initContent()
@@ -108,7 +123,7 @@ class ProductControllerCore extends FrontController
if (!$this->errors)
{
// Assign to the tempate the id of the virtuale product. "0" if the product is not downloadable.
- $this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int)($this->product->id)));
+ $this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int)$this->product->id));
// If the product is not active, it's the admin preview mode
if (!$this->product->active)
@@ -140,32 +155,39 @@ class ProductControllerCore extends FrontController
$pictures['pictures_'.$this->product->id.'_'.$file['index']] = $file['value'];
$texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
- $textFields = array();
- foreach ($texts as $textField)
- $textFields['textFields_'.$this->product->id.'_'.$textField['index']] = str_replace('
', "\n", $textField['value']);
+ $text_fields = array();
+ foreach ($texts as $text_field)
+ $text_fields['textFields_'.$this->product->id.'_'.$text_field['index']] = str_replace('
', "\n", $text_field['value']);
$this->context->smarty->assign(array(
'pictures' => $pictures,
- 'textFields' => $textFields));
+ 'textFields' => $text_fields));
// Assign template vars related to the category + execute hooks related to the category
$this->assignCategory();
// Assign template vars related to the price and tax
$this->assignPriceAndTax();
-
// Assign template vars related to the images
$this->assignImages();
// Assign attribute groups to the template
$this->assignAttributesGroups();
+ // Assign attributes combinations to the template
+ $this->assignAttributesCombinations();
+
// Pack management
- $this->context->smarty->assign('packItems', $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array());
+ $pack_items = $this->product->cache_is_pack ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
+ $this->context->smarty->assign('packItems', $pack_items);
$this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
+ if (isset($category->id) && $category->id)
+ $return_link = Tools::safeOutput($this->context->link->getCategoryLink($category));
+ else
+ $return_link = 'javascript: history.back();';
$this->context->smarty->assign(array(
'customizationFields' => ($this->product->customizable) ? $this->product->getCustomizationFields($this->context->language->id) : false,
'accessories' => $this->product->getAccessories($this->context->language->id),
- 'return_link' => (isset($category->id) && $category->id) ? Tools::safeOutput($this->context->link->getCategoryLink($category)) : 'javascript: history.back();',
+ 'return_link' => $return_link,
'product' => $this->product,
'product_manufacturer' => new Manufacturer((int)$this->product->id_manufacturer, $this->context->language->id),
'token' => Tools::getToken(false),
@@ -179,7 +201,7 @@ class ProductControllerCore extends FrontController
'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'),
'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'),
'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent'),
- 'display_qties' => (int)(Configuration::get('PS_DISPLAY_QTIES')),
+ 'display_qties' => (int)Configuration::get('PS_DISPLAY_QTIES'),
'display_ht' => !Tax::excludeTaxeOption(),
'currencySign' => $this->context->currency->sign,
'currencyRate' => $this->context->currency->conversion_rate,
@@ -187,7 +209,7 @@ class ProductControllerCore extends FrontController
'currencyBlank' => $this->context->currency->blank,
'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'),
'ENT_NOQUOTES' => ENT_NOQUOTES,
- 'outOfStockAllowed' => (int)(Configuration::get('PS_ORDER_OUT_OF_STOCK'))
+ 'outOfStockAllowed' => (int)Configuration::get('PS_ORDER_OUT_OF_STOCK')
));
}
@@ -201,38 +223,42 @@ class ProductControllerCore extends FrontController
*/
protected function assignPriceAndTax()
{
- $id_customer = (isset($this->context->customer) ? (int)($this->context->customer->id) : 0);
+ $id_customer = (isset($this->context->customer) ? (int)$this->context->customer->id : 0);
$group_reduction = (100 - Group::getReduction($id_customer)) / 100;
$id_group = (isset($this->context->customer) ? $this->context->customer->id_default_group : _PS_DEFAULT_CUSTOMER_GROUP_);
- $id_country = (int)($id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT'));
+ $id_country = (int)$id_customer ? Customer::getCurrentCountry($id_customer) : Configuration::get('PS_COUNTRY_DEFAULT');
// Tax
$tax = (float)$this->product->getTaxesRate(new Address((int)$this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}));
$this->context->smarty->assign('tax_rate', $tax);
- $productPriceWithTax = Product::getPriceStatic($this->product->id, true, null, 6);
+ $product_price_with_tax = Product::getPriceStatic($this->product->id, true, null, 6);
if (Product::$_taxCalculationMethod == PS_TAX_INC)
- $productPriceWithTax = Tools::ps_round($productPriceWithTax, 2);
- $productPriceWithoutEcoTax = (float)($productPriceWithTax - $this->product->ecotax);
+ $product_price_with_tax = Tools::ps_round($product_price_with_tax, 2);
+ $product_price_without_eco_tax = (float)$product_price_with_tax - $this->product->ecotax;
$ecotax_rate = (float)Tax::getProductEcotaxRate($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
- $ecotaxTaxAmount = Tools::ps_round($this->product->ecotax, 2);
+ $ecotax_tax_amount = Tools::ps_round($this->product->ecotax, 2);
if (Product::$_taxCalculationMethod == PS_TAX_INC && (int)Configuration::get('PS_TAX'))
- $ecotaxTaxAmount = Tools::ps_round($ecotaxTaxAmount * (1 + $ecotax_rate / 100), 2);
+ $ecotax_tax_amount = Tools::ps_round($ecotax_tax_amount * (1 + $ecotax_rate / 100), 2);
- $quantityDiscounts = SpecificPrice::getQuantityDiscounts((int)$this->product->id, $this->context->shop->getID(true), (int)$this->context->cookie->id_currency, $id_country, $id_group);
+ $id_currency = (int)$this->context->cookie->id_currency;
+ $id_product = (int)$this->product->id;
+ $id_shop = $this->context->shop->getID(true);
+ $quantity_discounts = SpecificPrice::getQuantityDiscounts($id_product, $id_shop, $id_currency, $id_country, $id_group);
- $productPrice = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false);
+ $product_price = $this->product->getPrice(Product::$_taxCalculationMethod == PS_TAX_INC, false);
+ $address = new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
$this->context->smarty->assign(array(
- 'quantity_discounts' => $this->formatQuantityDiscounts($quantityDiscounts, $productPrice, (float)$tax),
- 'ecotax_tax_inc' => $ecotaxTaxAmount,
+ 'quantity_discounts' => $this->formatQuantityDiscounts($quantity_discounts, $product_price, (float)$tax),
+ 'ecotax_tax_inc' => $ecotax_tax_amount,
'ecotax_tax_exc' => Tools::ps_round($this->product->ecotax, 2),
'ecotaxTax_rate' => $ecotax_rate,
- 'productPriceWithoutEcoTax' => (float)$productPriceWithoutEcoTax,
+ 'productPriceWithoutEcoTax' => (float)$product_price_without_eco_tax,
'group_reduction' => $group_reduction,
- 'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate(new Address($this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')})),
- 'ecotax' => (!count($this->errors) && $this->product->ecotax > 0 ? Tools::convertPrice((float)($this->product->ecotax)) : 0),
+ 'no_tax' => Tax::excludeTaxeOption() || !$this->product->getTaxesRate($address),
+ 'ecotax' => (!count($this->errors) && $this->product->ecotax > 0 ? Tools::convertPrice((float)$this->product->ecotax) : 0),
'tax_enabled' => Configuration::get('PS_TAX')
));
}
@@ -243,7 +269,7 @@ class ProductControllerCore extends FrontController
protected function assignImages()
{
$images = $this->product->getImages((int)$this->context->cookie->id_lang);
- $productImages = array();
+ $product_images = array();
foreach ($images as $k => $image)
{
if ($image['cover'])
@@ -253,21 +279,21 @@ class ProductControllerCore extends FrontController
$cover['id_image'] = (Configuration::get('PS_LEGACY_IMAGES') ? ($this->product->id.'-'.$image['id_image']) : $image['id_image']);
$cover['id_image_only'] = (int)$image['id_image'];
}
- $productImages[(int)($image['id_image'])] = $image;
+ $product_images[(int)$image['id_image']] = $image;
}
if (!isset($cover))
$cover = array('id_image' => $this->context->language->iso_code.'-default', 'legend' => 'No picture', 'title' => 'No picture');
$size = Image::getSize('large');
$this->context->smarty->assign(array(
- 'have_image' => Product::getCover((int)(Tools::getValue('id_product'))),
+ 'have_image' => Product::getCover((int)Tools::getValue('id_product')),
'cover' => $cover,
- 'imgWidth' => (int)($size['width']),
+ 'imgWidth' => (int)$size['width'],
'mediumSize' => Image::getSize('medium'),
'largeSize' => Image::getSize('large'),
'homeSize' => Image::getSize('home'),
'col_img_dir' => _PS_COL_IMG_DIR_));
- if (count($productImages))
- $this->context->smarty->assign('images', $productImages);
+ if (count($product_images))
+ $this->context->smarty->assign('images', $product_images);
}
/**
@@ -276,12 +302,13 @@ class ProductControllerCore extends FrontController
protected function assignAttributesGroups()
{
$colors = array();
- $attributesGroups = $this->product->getAttributesGroups($this->context->language->id); // @todo (RM) should only get groups and not all declination ?
- if (is_array($attributesGroups) && $attributesGroups)
+ // @todo (RM) should only get groups and not all declination ?
+ $attributes_groups = $this->product->getAttributesGroups($this->context->language->id);
+ if (is_array($attributes_groups) && $attributes_groups)
{
$groups = array();
- $combinationImages = $this->product->getCombinationImages($this->context->language->id);
- foreach ($attributesGroups as $k => $row)
+ $combination_images = $this->product->getCombinationImages($this->context->language->id);
+ foreach ($attributes_groups as $k => $row)
{
// Color management
if ((isset($row['attribute_color']) && $row['attribute_color']) || (file_exists(_PS_COL_IMG_DIR_.$row['id_attribute'].'.jpg')))
@@ -290,7 +317,7 @@ class ProductControllerCore extends FrontController
$colors[$row['id_attribute']]['name'] = $row['attribute_name'];
if (!isset($colors[$row['id_attribute']]['attributes_quantity']))
$colors[$row['id_attribute']]['attributes_quantity'] = 0;
- $colors[$row['id_attribute']]['attributes_quantity'] += (int)($row['quantity']);
+ $colors[$row['id_attribute']]['attributes_quantity'] += (int)$row['quantity'];
}
if (!isset($groups[$row['id_attribute_group']]))
{
@@ -301,17 +328,17 @@ class ProductControllerCore extends FrontController
);
$groups = array();
- $combinationImages = $this->product->getCombinationImages($this->context->language->id);
- foreach ($attributesGroups AS $k => $row)
+ $combination_images = $this->product->getCombinationImages($this->context->language->id);
+ foreach ($attributes_groups as $k => $row)
{
/* Color management */
- if ((isset($row['attribute_color']) AND $row['attribute_color']) OR (file_exists(_PS_COL_IMG_DIR_.$row['id_attribute'].'.jpg')))
+ if ((isset($row['attribute_color']) && $row['attribute_color']) || (file_exists(_PS_COL_IMG_DIR_.$row['id_attribute'].'.jpg')))
{
$colors[$row['id_attribute']]['value'] = $row['attribute_color'];
$colors[$row['id_attribute']]['name'] = $row['attribute_name'];
if (!isset($colors[$row['id_attribute']]['attributes_quantity']))
$colors[$row['id_attribute']]['attributes_quantity'] = 0;
- $colors[$row['id_attribute']]['attributes_quantity'] += (int)($row['quantity']);
+ $colors[$row['id_attribute']]['attributes_quantity'] += (int)$row['quantity'];
}
if (!isset($groups[$row['id_attribute_group']]))
{
@@ -324,81 +351,90 @@ class ProductControllerCore extends FrontController
$groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name'];
if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1)
- $groups[$row['id_attribute_group']]['default'] = (int)($row['id_attribute']);
+ $groups[$row['id_attribute_group']]['default'] = (int)$row['id_attribute'];
if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']]))
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0;
- $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int)($row['quantity']);
+ $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int)$row['quantity'];
- if($row['available_date'] != '0000-00-00' && $row['available_date'] != '0000-00-00 00:00:00')
- $availableDate = Tools::displayDate($row['available_date'], $this->context->language->id);
+ if ($row['available_date'] != '0000-00-00' && $row['available_date'] != '0000-00-00 00:00:00')
+ $available_date = Tools::displayDate($row['available_date'], $this->context->language->id);
else
- $availableDate = $row['available_date'];
+ $available_date = $row['available_date'];
+ if (isset($combination_images[$row['id_product_attribute']][0]['id_image']))
+ $id_image = $combination_images[$row['id_product_attribute']][0]['id_image'];
+ else
+ $id_image = -1;
$combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name'];
- $combinations[$row['id_product_attribute']]['attributes'][] = (int)($row['id_attribute']);
- $combinations[$row['id_product_attribute']]['price'] = (float)($row['price']);
- $combinations[$row['id_product_attribute']]['ecotax'] = (float)($row['ecotax']);
- $combinations[$row['id_product_attribute']]['weight'] = (float)($row['weight']);
- $combinations[$row['id_product_attribute']]['quantity'] = (int)($row['quantity']);
+ $combinations[$row['id_product_attribute']]['attributes'][] = (int)$row['id_attribute'];
+ $combinations[$row['id_product_attribute']]['price'] = (float)$row['price'];
+ $combinations[$row['id_product_attribute']]['ecotax'] = (float)$row['ecotax'];
+ $combinations[$row['id_product_attribute']]['weight'] = (float)$row['weight'];
+ $combinations[$row['id_product_attribute']]['quantity'] = (int)$row['quantity'];
$combinations[$row['id_product_attribute']]['reference'] = $row['reference'];
$combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact'];
$combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity'];
- $combinations[$row['id_product_attribute']]['available_date'] = $availableDate;
- $combinations[$row['id_product_attribute']]['id_image'] = isset($combinationImages[$row['id_product_attribute']][0]['id_image']) ? $combinationImages[$row['id_product_attribute']][0]['id_image'] : -1;
+ $combinations[$row['id_product_attribute']]['available_date'] = $available_date;
+ $combinations[$row['id_product_attribute']]['id_image'] = $id_image;
}
//wash attributes list (if some attributes are unavailables and if allowed to wash it)
if (!Product::isAvailableWhenOutOfStock($this->product->out_of_stock) && Configuration::get('PS_DISP_UNAVAILABLE_ATTR') == 0)
{
- foreach ($groups AS &$group)
- foreach ($group['attributes_quantity'] AS $key => &$quantity)
+ foreach ($groups as &$group)
+ foreach ($group['attributes_quantity'] as $key => &$quantity)
if (!$quantity)
unset($group['attributes'][$key]);
- foreach ($colors AS $key => $color)
+ foreach ($colors as $key => $color)
if (!$color['attributes_quantity'])
unset($colors[$key]);
}
- foreach ($combinations AS $id_product_attribute => $comb)
+ foreach ($combinations as $id_product_attribute => $comb)
{
- $attributeList = '';
- foreach ($comb['attributes'] AS $id_attribute)
- $attributeList .= '\''.(int)($id_attribute).'\',';
- $attributeList = rtrim($attributeList, ',');
- $combinations[$id_product_attribute]['list'] = $attributeList;
+ $attribute_list = '';
+ foreach ($comb['attributes'] as $id_attribute)
+ $attribute_list .= '\''.(int)$id_attribute.'\',';
+ $attribute_list = rtrim($attribute_list, ',');
+ $combinations[$id_product_attribute]['list'] = $attribute_list;
}
+ // if we need to display a combination and not a single product
+ /*if (true)
+ {
+
+ }*/
$this->context->smarty->assign(array(
'groups' => $groups,
'combinaisons' => $combinations, /* Kept for compatibility purpose only */
'combinations' => $combinations,
- 'colors' => (sizeof($colors)) ? $colors : false,
- 'combinationImages' => $combinationImages));
+ 'colors' => (count($colors)) ? $colors : false,
+ 'combinationImages' => $combination_images));
}
$groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name'];
if ($row['default_on'] && $groups[$row['id_attribute_group']]['default'] == -1)
- $groups[$row['id_attribute_group']]['default'] = (int)($row['id_attribute']);
+ $groups[$row['id_attribute_group']]['default'] = (int)$row['id_attribute'];
if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']]))
$groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0;
- $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int)($row['quantity']);
+ $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += (int)$row['quantity'];
- if($row['available_date'] != '0000-00-00 00:00:00' && $row['available_date'] != '0000-00-00')
- $availableDate = Tools::displayDate($row['available_date'], $this->context->language->id);
+ if ($row['available_date'] != '0000-00-00 00:00:00' && $row['available_date'] != '0000-00-00')
+ $available_date = Tools::displayDate($row['available_date'], $this->context->language->id);
else
- $availableDate = $row['available_date'];
+ $available_date = $row['available_date'];
$combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name'];
- $combinations[$row['id_product_attribute']]['attributes'][] = (int)($row['id_attribute']);
- $combinations[$row['id_product_attribute']]['price'] = (float)($row['price']);
- $combinations[$row['id_product_attribute']]['ecotax'] = (float)($row['ecotax']);
- $combinations[$row['id_product_attribute']]['weight'] = (float)($row['weight']);
- $combinations[$row['id_product_attribute']]['quantity'] = (int)($row['quantity']);
+ $combinations[$row['id_product_attribute']]['attributes'][] = (int)$row['id_attribute'];
+ $combinations[$row['id_product_attribute']]['price'] = (float)$row['price'];
+ $combinations[$row['id_product_attribute']]['ecotax'] = (float)$row['ecotax'];
+ $combinations[$row['id_product_attribute']]['weight'] = (float)$row['weight'];
+ $combinations[$row['id_product_attribute']]['quantity'] = (int)$row['quantity'];
$combinations[$row['id_product_attribute']]['reference'] = $row['reference'];
$combinations[$row['id_product_attribute']]['unit_impact'] = $row['unit_price_impact'];
$combinations[$row['id_product_attribute']]['minimal_quantity'] = $row['minimal_quantity'];
- $combinations[$row['id_product_attribute']]['available_date'] = $availableDate;
- if (isset($combinationImages[$row['id_product_attribute']][0]['id_image']))
- $combinations[$row['id_product_attribute']]['id_image'] = $combinationImages[$row['id_product_attribute']][0]['id_image'];
+ $combinations[$row['id_product_attribute']]['available_date'] = $available_date;
+ if (isset($combination_images[$row['id_product_attribute']][0]['id_image']))
+ $combinations[$row['id_product_attribute']]['id_image'] = $combination_images[$row['id_product_attribute']][0]['id_image'];
else
$combinations[$row['id_product_attribute']]['id_image'] = -1;
}
@@ -417,21 +453,32 @@ class ProductControllerCore extends FrontController
foreach ($combinations as $id_product_attribute => $comb)
{
- $attributeList = '';
+ $attribute_list = '';
foreach ($comb['attributes'] as $id_attribute)
- $attributeList .= '\''.(int)($id_attribute).'\',';
- $attributeList = rtrim($attributeList, ',');
- $combinations[$id_product_attribute]['list'] = $attributeList;
+ $attribute_list .= '\''.(int)$id_attribute.'\',';
+ $attribute_list = rtrim($attribute_list, ',');
+ $combinations[$id_product_attribute]['list'] = $attribute_list;
}
$this->context->smarty->assign(array(
'groups' => $groups,
'combinaisons' => $combinations, /* Kept for compatibility purpose only */
'combinations' => $combinations,
'colors' => (count($colors)) ? $colors : false,
- 'combinationImages' => $combinationImages));
+ 'combinationImages' => $combination_images));
}
}
+ /**
+ * Get and assign attributes combinations informations
+ */
+ protected function assignAttributesCombinations()
+ {
+ $attributes_combinations = Product::getAttributesInformationsByProduct($this->product->id);
+ foreach ($attributes_combinations as &$ac)
+ $ac = array_map('Tools::str2url', $ac);
+ $this->context->smarty->assign('attributesCombinations', $attributes_combinations);
+ }
+
/**
* Assign template vars related to category
*/
@@ -450,7 +497,7 @@ class ProductControllerCore extends FrontController
}
else if (isset($regs[5]) && is_numeric($regs[5]))
{
- if (Product::idIsOnCategoryId((int)($this->product->id), array('0' => array('id_category' => (int)$regs[5]))))
+ if (Product::idIsOnCategoryId((int)$this->product->id, array('0' => array('id_category' => (int)$regs[5]))))
$category = new Category($regs[5], (int)$this->context->cookie->id_lang);
}
}
@@ -465,8 +512,8 @@ class ProductControllerCore extends FrontController
'path' => Tools::getPath($category->id, $this->product->name, true),
'category' => $category,
'subCategories' => $category->getSubCategories($this->context->language->id, true),
- 'id_category_current' => (int)($category->id),
- 'id_category_parent' => (int)($category->id_parent),
+ 'id_category_current' => (int)$category->id,
+ 'id_category_parent' => (int)$category->id_parent,
'return_category_name' => Tools::safeOutput($category->name)
));
}
@@ -492,83 +539,88 @@ class ProductControllerCore extends FrontController
public function pictureUpload(Product $product, Cart $cart)
{
- if (!$fieldIds = $this->product->getCustomizationFieldIds())
+ if (!$field_ids = $this->product->getCustomizationFieldIds())
return false;
- $authorizedFileFields = array();
- foreach ($fieldIds as $fieldId)
- if ($fieldId['type'] == Product::CUSTOMIZE_FILE)
- $authorizedFileFields[(int)($fieldId['id_customization_field'])] = 'file'.(int)($fieldId['id_customization_field']);
- $indexes = array_flip($authorizedFileFields);
- foreach ($_FILES as $fieldName => $file)
- if (in_array($fieldName, $authorizedFileFields) && isset($file['tmp_name']) && !empty($file['tmp_name']))
+ $authorized_file_fields = array();
+ foreach ($field_ids as $field_id)
+ if ($field_id['type'] == Product::CUSTOMIZE_FILE)
+ $authorized_file_fields[(int)$field_id['id_customization_field']] = 'file'.(int)$field_id['id_customization_field'];
+ $indexes = array_flip($authorized_file_fields);
+ foreach ($_FILES as $field_name => $file)
+ if (in_array($field_name, $authorized_file_fields) && isset($file['tmp_name']) && !empty($file['tmp_name']))
{
- $fileName = md5(uniqid(rand(), true));
- if ($error = checkImage($file, (int)(Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE'))))
+ $file_name = md5(uniqid(rand(), true));
+ if ($error = checkImage($file, (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE')))
$this->errors[] = $error;
- if ($error || (!$tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS') || !move_uploaded_file($file['tmp_name'], $tmpName)))
+ $product_picture_width = (int)Configuration::get('PS_PRODUCT_PICTURE_WIDTH');
+ $product_picture_height = (int)Configuration::get('PS_PRODUCT_PICTURE_HEIGHT');
+ if ($error || (!$tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS') || !move_uploaded_file($file['tmp_name'], $tmp_name)))
return false;
/* Original file */
- else if (!imageResize($tmpName, _PS_UPLOAD_DIR_.$fileName))
+ else if (!imageResize($tmp_name, _PS_UPLOAD_DIR_.$file_name))
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
/* A smaller one */
- else if (!imageResize($tmpName, _PS_UPLOAD_DIR_.$fileName.'_small', (int)(Configuration::get('PS_PRODUCT_PICTURE_WIDTH')), (int)(Configuration::get('PS_PRODUCT_PICTURE_HEIGHT'))))
+ else if (!imageResize($tmp_name, _PS_UPLOAD_DIR_.$file_name.'_small', $product_picture_width, $product_picture_height))
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
- else if (!chmod(_PS_UPLOAD_DIR_.$fileName, 0777) || !chmod(_PS_UPLOAD_DIR_.$fileName.'_small', 0777))
+ else if (!chmod(_PS_UPLOAD_DIR_.$file_name, 0777) || !chmod(_PS_UPLOAD_DIR_.$file_name.'_small', 0777))
$this->errors[] = Tools::displayError('An error occurred during the image upload.');
else
{
// Store customization in database
- $cart->addPictureToProduct($this->product->id, $indexes[$fieldName], Product::CUSTOMIZE_FILE, $fileName);
+ $cart->addPictureToProduct($this->product->id, $indexes[$field_name], Product::CUSTOMIZE_FILE, $file_name);
}
- unlink($tmpName);
+ unlink($tmp_name);
}
return true;
}
public function textRecord(Product $product, Cart $cart)
{
- if (!$fieldIds = $this->product->getCustomizationFieldIds())
+ if (!$field_ids = $this->product->getCustomizationFieldIds())
return false;
- $authorizedTextFields = array();
- foreach ($fieldIds as $fieldId)
- if ($fieldId['type'] == Product::CUSTOMIZE_TEXTFIELD)
- $authorizedTextFields[(int)($fieldId['id_customization_field'])] = 'textField'.(int)($fieldId['id_customization_field']);
- $indexes = array_flip($authorizedTextFields);
- foreach ($_POST as $fieldName => $value)
- if (in_array($fieldName, $authorizedTextFields) && !empty($value))
+ $authorized_text_fields = array();
+ foreach ($field_ids as $field_id)
+ if ($field_id['type'] == Product::CUSTOMIZE_TEXTFIELD)
+ $authorized_text_fields[(int)$field_id['id_customization_field']] = 'textField'.(int)$field_id['id_customization_field'];
+ $indexes = array_flip($authorized_text_fields);
+ foreach ($_POST as $field_name => $value)
+ if (in_array($field_name, $authorized_text_fields) && !empty($value))
{
if (!Validate::isMessage($value))
$this->errors[] = Tools::displayError('Invalid message');
else
- $cart->addTextFieldToProduct($this->product->id, $indexes[$fieldName], Product::CUSTOMIZE_TEXTFIELD, $value);
+ $cart->addTextFieldToProduct($this->product->id, $indexes[$field_name], Product::CUSTOMIZE_TEXTFIELD, $value);
}
- else if (in_array($fieldName, $authorizedTextFields) && empty($value))
- $cart->deleteCustomizationToProduct((int)($this->product->id), $indexes[$fieldName]);
+ else if (in_array($field_name, $authorized_text_fields) && empty($value))
+ $cart->deleteCustomizationToProduct((int)$this->product->id, $indexes[$field_name]);
}
public function formTargetFormat()
{
- $customizationFormTarget = Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']));
+ $customization_form_target = Tools::safeOutput(urldecode($_SERVER['REQUEST_URI']));
foreach ($_GET as $field => $value)
if (strncmp($field, 'group_', 6) == 0)
- $customizationFormTarget = preg_replace('/&group_([[:digit:]]+)=([[:digit:]]+)/', '', $customizationFormTarget);
+ $customization_form_target = preg_replace('/&group_([[:digit:]]+)=([[:digit:]]+)/', '', $customization_form_target);
if (isset($_POST['quantityBackup']))
- $this->context->smarty->assign('quantityBackup', (int)($_POST['quantityBackup']));
- $this->context->smarty->assign('customizationFormTarget', $customizationFormTarget);
+ $this->context->smarty->assign('quantityBackup', (int)$_POST['quantityBackup']);
+ $this->context->smarty->assign('customizationFormTarget', $customization_form_target);
}
- public function formatQuantityDiscounts($specificPrices, $price, $taxRate)
+ public function formatQuantityDiscounts($specific_prices, $price, $tax_rate)
{
- foreach ($specificPrices as $key => &$row)
+ foreach ($specific_prices as $key => &$row)
{
$row['quantity'] = &$row['from_quantity'];
if ($row['price'] != 0) // The price may be directly set
{
- $cur_price = (Product::$_taxCalculationMethod == PS_TAX_EXC ? $row['price'] : $row['price'] * (1 + $taxRate / 100));
+ $cur_price = (Product::$_taxCalculationMethod == PS_TAX_EXC ? $row['price'] : $row['price'] * (1 + $tax_rate / 100));
if ($row['reduction_type'] == 'amount')
- $cur_price = Product::$_taxCalculationMethod == PS_TAX_INC ? $cur_price - $row['reduction'] : $cur_price - ($row['reduction'] / (1 + $taxRate / 100));
+ if (Product::$_taxCalculationMethod == PS_TAX_INC)
+ $cur_price = $cur_price - $row['reduction'];
+ else
+ $cur_price = $cur_price - ($row['reduction'] / (1 + $tax_rate / 100));
else
$cur_price = $cur_price * ( 1 - ($row['reduction']));
@@ -581,14 +633,14 @@ class ProductControllerCore extends FrontController
$reduction_amount = $row['reduction'];
if (!$row['id_currency'])
$reduction_amount = Tools::convertPrice($reduction_amount, $this->context->currency->id);
- $row['real_value'] = Product::$_taxCalculationMethod == PS_TAX_INC ? $row['reduction'] : $row['reduction'] / (1 + $taxRate / 100);
+ $row['real_value'] = Product::$_taxCalculationMethod == PS_TAX_INC ? $row['reduction'] : $row['reduction'] / (1 + $tax_rate / 100);
}
else
$row['real_value'] = $row['reduction'] * 100;
}
- $row['nextQuantity'] = (isset($specificPrices[$key + 1]) ? (int)($specificPrices[$key + 1]['from_quantity']) : -1);
+ $row['nextQuantity'] = (isset($specific_prices[$key + 1]) ? (int)$specific_prices[$key + 1]['from_quantity'] : -1);
}
- return $specificPrices;
+ return $specific_prices;
}
}
diff --git a/themes/prestashop/js/product.js b/themes/prestashop/js/product.js
index c3c05ce5d..f6b2f1a71 100644
--- a/themes/prestashop/js/product.js
+++ b/themes/prestashop/js/product.js
@@ -553,3 +553,68 @@ function colorPickerClick(elt)
$('#color_pick_hidden').val(id_attribute);
findCombination();
}
+
+
+function getProductAttribute()
+{
+ // get product attribute id
+ product_attribute_id = $('#idCombination').val();
+ product_id = $('#product_page_product_id').val();
+
+ // get every attributes values
+ request = '';
+ //create a temporary 'tab_attributes' array containing the choices of the customer
+ var tab_attributes = new Array();
+ $('div#attributes select, div#attributes input[type=hidden], div#attributes input[type=radio]:checked').each(function(){
+ tab_attributes.push($(this).val());
+ });
+
+ // build new request
+ for (i in attributesCombinations)
+ for (a in tab_attributes)
+ if (attributesCombinations[i]['id_attribute'] == tab_attributes[a])
+ request += '&'+attributesCombinations[i]['group']+'='+attributesCombinations[i]['attribute'];
+ request = request.replace(request.substring(0, 1), '#');
+ url = window.location+'';
+
+ // redirection
+ if (url.indexOf('#') != -1)
+ url = url.substring(0, url.indexOf('#'));
+ window.location = url+request;
+}
+
+$(document).ready(function(){
+ url = window.location+'';
+ // if we need to load a specific combination
+ if (url.indexOf('#') != -1)
+ {
+ // get the params to fill
+ params = url.substring(url.indexOf('#') + 1, url.length);
+ tabParams = params.split('&');
+ tabValues = new Array();
+ for (i in tabParams)
+ tabValues.push(tabParams[i].split('='));
+ product_id = $('#product_page_product_id').val();
+ // fill html with values
+ $('.color_pick').removeClass('selected');
+ count = 0;
+ for (z in tabValues)
+ for (a in attributesCombinations)
+ if (attributesCombinations[a]['group'] == tabValues[z][0]
+ && attributesCombinations[a]['attribute'] == tabValues[z][1])
+ {
+ count++;
+ // add class 'selected' to the selected color
+ $('#color_'+attributesCombinations[a]['id_attribute']).addClass('selected');
+ $('input:radio[value='+attributesCombinations[a]['id_attribute']+']').attr('checked', 'checked');
+ $('input:hidden[name=group_'+attributesCombinations[a]['id_attribute_group']+']').val(attributesCombinations[a]['id_attribute']);
+ $('select[name=group_'+attributesCombinations[a]['id_attribute_group']+']').val(attributesCombinations[a]['id_attribute']);
+ }
+ // find combination
+ if (count == tabValues.length)
+ findCombination();
+ // no combination found = removing attributes from url
+ else
+ window.location = url.substring(0, url.indexOf('#'));
+ }
+});
\ No newline at end of file
diff --git a/themes/prestashop/product.tpl b/themes/prestashop/product.tpl
index 952dc81f0..4c23abbfd 100644
--- a/themes/prestashop/product.tpl
+++ b/themes/prestashop/product.tpl
@@ -111,6 +111,19 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus
addCombination({$idCombination|intval}, new Array({$combination.list}), {$combination.quantity}, {$combination.price}, {$combination.ecotax}, {$combination.id_image}, '{$combination.reference|addslashes}', {$combination.unit_impact}, {$combination.minimal_quantity}, '{$combination.available_date}');
{/foreach}
{/if}
+
+{if isset($attributesCombinations)}
+ // Combinations attributes informations
+ var attributesCombinations = new Array();
+ {foreach from=$attributesCombinations key=id item=aC}
+ tabInfos = new Array();
+ tabInfos['id_attribute'] = '{$aC.id_attribute|intval}';
+ tabInfos['attribute'] = '{$aC.attribute}';
+ tabInfos['group'] = '{$aC.group}';
+ tabInfos['id_attribute_group'] = '{$aC.id_attribute_group|intval}';
+ attributesCombinations.push(tabInfos);
+ {/foreach}
+{/if}
//]]>
@@ -290,7 +303,7 @@ var fieldRequired = '{l s='Please fill in all required fields, then save the cus
{assign var="groupName" value="group_$id_attribute_group"}