From b972311a131eda7273d72edddb80f34dc3c63905 Mon Sep 17 00:00:00 2001 From: Casper Kromann Nielsen Date: Mon, 10 Feb 2020 11:05:51 +0100 Subject: [PATCH] Added support for product attributes - multi content all over --- clerk.php | 13 ++++---- controllers/front/product.php | 36 +++++++++++++++++++++++ views/templates/hook/visitor_tracking.tpl | 10 ++++--- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/clerk.php b/clerk.php index e90bf11..d622311 100644 --- a/clerk.php +++ b/clerk.php @@ -67,7 +67,7 @@ public function __construct() $this->api = new Clerk_Api(); $this->name = 'clerk'; $this->tab = 'advertising_marketing'; - $this->version = '5.3.1'; + $this->version = '5.3.2'; $this->author = 'Clerk'; $this->need_instance = 0; $this->ps_versions_compliancy = array('min' => '1.5', 'max' => _PS_VERSION_); @@ -1578,7 +1578,7 @@ public function renderForm() '
  • Errors will be visible.
  • '. '
  • Clerk logger can catch all errors.
  • '. '
  • Remember to disable it again after use!
  • '. - '
  • It\'s not best practice to have it enabled in production.
  • '. + '
  • It\'s not best practice to have it enabled in production.
  • >'. '
  • it\'s only recommended for at very short period af time for debug use.
  • '. ''. '

    Step By Step Guide to disable debug mode

    '. @@ -1878,6 +1878,8 @@ public function hookFooter() $controller = $this->context->controller; $cookie = $this->context->cookie; + $popup = ''; + //Determine if powerstep is enabled if (Configuration::get('CLERK_POWERSTEP_ENABLED', $this->context->language->id, null, $this->context->shop->id)) { if ($cookie->clerk_show_powerstep == true) { @@ -1954,7 +1956,7 @@ public function hookFooter() 'clerk_datasync_include_out_of_stock_products' => Configuration::get('CLERK_DATASYNC_INCLUDE_OUT_OF_STOCK_PRODUCTS', $this->context->language->id, null, $this->context->shop->id), 'clerk_datasync_collect_emails' => Configuration::get('CLERK_DATASYNC_COLLECT_EMAILS', $this->context->language->id, null, $this->context->shop->id), 'exit_intent_enabled' => (bool)Configuration::get('CLERK_EXIT_INTENT_ENABLED', $this->context->language->id, null, $this->context->shop->id), - 'exit_intent_template' => Tools::strtolower(str_replace(' ', '-', Configuration::get('CLERK_EXIT_INTENT_TEMPLATE', $this->context->language->id, null, $this->context->shop->id))), + 'exit_intent_template' => explode(',',Tools::strtolower(str_replace(' ', '-', Configuration::get('CLERK_EXIT_INTENT_TEMPLATE', $this->context->language->id, null, $this->context->shop->id)))), 'product_enabled' => (bool)Configuration::get('CLERK_PRODUCT_ENABLED', $this->context->language->id, null, $this->context->shop->id), 'product_template' => Tools::strtolower(str_replace(' ', '-', Configuration::get('CLERK_PRODUCT_TEMPLATE', $this->context->language->id, null, $this->context->shop->id))), 'cart_enabled' => (bool)Configuration::get('CLERK_CART_ENABLED', $this->context->language->id, null, $this->context->shop->id), @@ -2001,7 +2003,6 @@ public function hookDisplayShoppingCartFooter($params) $ProductsIds[] = $PreProductId['id_product']; } - $ProductsIds = implode(",", $ProductsIds); $this->context->smarty->assign( @@ -2026,7 +2027,9 @@ public function hookDisplayShoppingCartFooter($params) public function hookDisplayFooterProduct($params) { - if (Configuration::get('CLERK_PRODUCT_ENABLED', $this->context->language->id, null, $this->context->shop->id)) { + $context = Context::getContext(); + + if (Configuration::get('CLERK_PRODUCT_ENABLED', $context->language->id, null, $this->context->shop->id)) { $Contents = explode(',', Configuration::get('CLERK_PRODUCT_TEMPLATE', $this->context->language->id, null, $this->context->shop->id)); diff --git a/controllers/front/product.php b/controllers/front/product.php index cb9fa8e..0ea6ebf 100644 --- a/controllers/front/product.php +++ b/controllers/front/product.php @@ -144,14 +144,50 @@ public function getJsonResponse() $product = new Product(); $products = $product->getProducts($this->getLanguageId(), $this->offset, $this->limit, $this->order_by, $this->order, false, true); + $context = Context::getContext(); + $response = array(); $fields = array_flip($this->fieldMap); foreach ($products as $product) { + + + $productRaw = new Product ($product['id_product'], $context->language->id); + + $combinations = $productRaw->getAttributeCombinations((int)$context->language->id, true); + + $attributes = []; + + if (count($combinations) > 0) { + + foreach ($combinations as $combination) { + + if(!isset($attributes[$combination['group_name']])) { + + $attributes[$combination['group_name']][] = $combination['attribute_name']; + + } else { + + if (!in_array($combination['attribute_name'], $attributes[$combination['group_name']])) { + + $attributes[$combination['group_name']][] = $combination['attribute_name']; + + } + } + + } + + } + $item = array(); foreach ($this->fields as $field) { $field = str_replace(' ','',$field); + if ($attributes && array_key_exists($field, $attributes)){ + + $item[$field] = $attributes[$field]; + + } if (array_key_exists($field, array_flip($this->fieldMap))) { $item[$field] = $product[$fields[$field]]; } elseif (isset($product[$field])) { diff --git a/views/templates/hook/visitor_tracking.tpl b/views/templates/hook/visitor_tracking.tpl index b636031..5bad5b9 100644 --- a/views/templates/hook/visitor_tracking.tpl +++ b/views/templates/hook/visitor_tracking.tpl @@ -75,8 +75,10 @@ } - - +{foreach $exit_intent_template as $template} + + +{/foreach} {/if} \ No newline at end of file