Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix feature show in product page #149

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions 1DB_changes/okay_clean.sql
Expand Up @@ -690,6 +690,7 @@ CREATE TABLE `ok_features` (
`to_index_new_value` tinyint(1) DEFAULT '0',
`description` mediumtext COLLATE utf8mb4_unicode_ci,
`visible` tinyint(1) DEFAULT '1',
`show_in_product` INT(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
KEY `position` (`position`),
KEY `in_filter` (`in_filter`)
Expand Down
4 changes: 3 additions & 1 deletion 1DB_changes/update_4.3.0.sql
Expand Up @@ -2,4 +2,6 @@ UPDATE `ok_menu_items` SET `url` = 'all-products/filter-discounted' WHERE `url`
DELETE FROM ok_lang_pages WHERE page_id IN (SELECT id FROM ok_pages WHERE url IN ('bestsellers', 'discounted'));
DELETE FROM ok_pages WHERE url IN ('bestsellers', 'discounted');

INSERT INTO ok_settings (param, value) VALUES('features_max_count_products', 10);
INSERT INTO ok_settings (param, value) VALUES('features_max_count_products', 10);

ALTER TABLE `ok_features` ADD `show_in_product` INT(2) NOT NULL DEFAULT '1' AFTER `visible`;
1 change: 1 addition & 0 deletions Okay/Entities/FeaturesEntity.php
Expand Up @@ -22,6 +22,7 @@ class FeaturesEntity extends Entity
'to_index_new_value',
'external_id',
'visible',
'show_in_product',
];

protected static $langFields = [
Expand Down
3 changes: 2 additions & 1 deletion Okay/Helpers/ProductsHelper.php
Expand Up @@ -249,7 +249,8 @@ public function attachFeatures(array $products, array $featuresFilter = [], arra
}

$featuresFilter['visible'] = true;

$featuresFilter['show_in_product'] = 1;

foreach ($featuresEntity->find($featuresFilter) as $f) {
$features[$f->id] = $f;
}
Expand Down
1 change: 1 addition & 0 deletions backend/Controllers/FeaturesAdmin.php
Expand Up @@ -29,6 +29,7 @@ public function fetch(

$ids = $featuresRequest->postCheck();
$action = $featuresRequest->postAction();

if (is_array($ids)) {
switch($action) {
case 'enable': {
Expand Down
1 change: 1 addition & 0 deletions backend/Requests/BackendFeaturesRequest.php
Expand Up @@ -41,6 +41,7 @@ public function postFeature()
$feature->visible = $this->request->post('visible', 'int');
$feature->to_index_new_value = $this->request->post('to_index_new_value');
$feature->description = $this->request->post('description');
$feature->show_in_product = $this->request->post('show_in_product');

$feature->url = preg_replace("/[\s]+/ui", '', $feature->url);
$feature->url = strtolower(preg_replace("/[^0-9a-z]+/ui", '', $feature->url));
Expand Down
14 changes: 14 additions & 0 deletions backend/design/html/feature.tpl
Expand Up @@ -130,6 +130,20 @@
</div>
</div>
</div>
<div class="heading_label__switch heading_label__switch--not_label">
<div class="heading_label boxes_inline">
{$btr->feature_show_in_product|escape}
</div>
<div class="boxes_inline">
<div class="okay_switch clearfix">
<label class="switch switch-default">
<input class="switch-input" name="show_in_product" value='1' type="checkbox" {if $feature->show_in_product}checked=""{/if}/>
<span class="switch-label"></span>
<span class="switch-handle"></span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions backend/design/html/features.tpl
Expand Up @@ -100,6 +100,7 @@
<div class="okay_list_heading okay_list_status">{$btr->general_enable|escape}</div>
<div class="okay_list_heading okay_list_url_status">{$btr->feature_url_in_product_short|escape}</div>
<div class="okay_list_heading okay_list_status">{$btr->features_in_filter|escape}</div>
<div class="okay_list_heading okay_list_status">{$btr->feature_show_in_product|escape}</div>
<div class="okay_list_heading okay_list_close"></div>
</div>
{*Параметры элемента*}
Expand Down Expand Up @@ -175,6 +176,14 @@
<span class="switch-handle"></span>
</label>
</div>
<div class="okay_list_boding show_in_product">
{*show_in_product*}
<label class="switch switch-default">
<input class="switch-input fn_ajax_action {if $feature->show_in_product}fn_active_class{/if}" data-controller="feature" data-action="show_in_product" data-id="{$feature->id}" name="show_in_product" value="1" type="checkbox" {if $feature->show_in_product}checked=""{/if}/>
<span class="switch-label"></span>
<span class="switch-handle"></span>
</label>
</div>
<div class="okay_list_boding okay_list_close">
{*delete*}
<button data-hint="{$btr->features_delete|escape}" type="button" class="btn_close fn_remove hint-bottom-right-t-info-s-small-mobile hint-anim" data-toggle="modal" data-target="#fn_action_modal" onclick="success_action($(this));">
Expand Down
1 change: 1 addition & 0 deletions backend/lang/en.php
Expand Up @@ -91,6 +91,7 @@
$lang['feature_updated'] = 'Feature updated';
$lang['feature_value_id'] = 'Value ID';
$lang['feature_url_in_product'] = 'Filter reference in product';
$lang['feature_show_in_product'] = 'Show in product';
$lang['feature_url_in_product_short'] = 'Reference in product';
$lang['features_add'] = 'Add feature';
$lang['features_delete'] = 'Delete feature';
Expand Down
1 change: 1 addition & 0 deletions backend/lang/ru.php
Expand Up @@ -91,6 +91,7 @@
$lang['feature_updated'] = 'Свойство обновлено';
$lang['feature_value_id'] = 'ID значения';
$lang['feature_url_in_product'] = 'Ссылка на фильтр в товаре';
$lang['feature_show_in_product'] = 'Показать в товаре ';
$lang['feature_url_in_product_short'] = 'Ссылка в товаре';
$lang['features_add'] = 'Добавить свойство';
$lang['features_delete'] = 'Удалить свойство';
Expand Down
1 change: 1 addition & 0 deletions backend/lang/ua.php
Expand Up @@ -91,6 +91,7 @@
$lang['feature_updated'] = 'Властивість оновлена';
$lang['feature_value_id'] = 'ID значення';
$lang['feature_url_in_product'] = 'Посилання на фільтр у товарі';
$lang['feature_show_in_product'] = 'Відображати у товарі ';
$lang['feature_url_in_product_short'] = 'Посилання в товарі';
$lang['features_add'] = 'Додати властивість';
$lang['features_delete'] = 'Видалити властивість';
Expand Down