Skip to content

Commit

Permalink
Added support for product attributes - multi content all over
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperKN committed Feb 10, 2020
1 parent 8fe48e2 commit b972311
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 9 deletions.
13 changes: 8 additions & 5 deletions clerk.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down Expand Up @@ -1578,7 +1578,7 @@ public function renderForm()
'<li style="color: red;">Errors will be visible.</li>'.
'<li style="color: red;">Clerk logger can catch all errors.</li>'.
'<li style="color: red;">Remember to disable it again after use!</li>'.
'<li style="color: red;">It\'s not best practice to have it enabled in production.</li>'.
'<li style="color: red;">It\'s not best practice to have it enabled in production.</li>>'.
'<li style="color: red;">it\'s only recommended for at very short period af time for debug use.</li>'.
'</ul>'.
'</br><p><strong>Step By Step Guide to disable debug mode</strong></p>'.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -2001,7 +2003,6 @@ public function hookDisplayShoppingCartFooter($params)
$ProductsIds[] = $PreProductId['id_product'];

}

$ProductsIds = implode(",", $ProductsIds);

$this->context->smarty->assign(
Expand All @@ -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));

Expand Down
36 changes: 36 additions & 0 deletions controllers/front/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
10 changes: 6 additions & 4 deletions views/templates/hook/visitor_tracking.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@
}
</style>
<span class="clerk exit-intent"
data-template="@{$exit_intent_template}"
data-exit-intent="true">
</span>
{foreach $exit_intent_template as $template}
<span class="clerk exit-intent"
data-template="@{$template}"
data-exit-intent="true">
</span>
{/foreach}
{/if}

0 comments on commit b972311

Please sign in to comment.