Skip to content

Commit

Permalink
[FIX] Product images deleting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Seiger committed Mar 21, 2024
1 parent a3b3429 commit b5c7561
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ of Evolution CMS for seamless and efficient **online commerce**.
- [x] Number Attribute.
- [ ] Checkbox Attribute.
- [ ] Radio Attribute.
- [x] Select Attribute.
- [x] Multiselect Attribute.
- [ ] Select Attribute.
- [ ] Multiselect Attribute.
- [x] Text Attribute.
- [ ] TextArea Attribute.
- [ ] RichText Attribute.
Expand All @@ -42,6 +42,7 @@ of Evolution CMS for seamless and efficient **online commerce**.
- [ ] Image Attribute.
- [ ] File Attribute.
- [ ] Geolocation Attribute.
- [ ] Constructor Attribute.
- [ ] Dynamic Filters for Product Search.
- [ ] Promo Code System.
- [ ] Customer Reviews and Ratings.
Expand Down
5 changes: 3 additions & 2 deletions docs/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ of Evolution CMS for seamless and efficient **online commerce**.
- [x] Number Attribute.
- [ ] Checkbox Attribute.
- [ ] Radio Attribute.
- [x] Select Attribute.
- [x] Multiselect Attribute.
- [ ] Select Attribute.
- [ ] Multiselect Attribute.
- [x] Text Attribute.
- [ ] TextArea Attribute.
- [ ] RichText Attribute.
Expand All @@ -48,6 +48,7 @@ of Evolution CMS for seamless and efficient **online commerce**.
- [ ] Image Attribute.
- [ ] File Attribute.
- [ ] Geolocation Attribute.
- [ ] Constructor Attribute.
- [ ] Dynamic Filters for Product Search.
- [ ] Promo Code System.
- [ ] Customer Reviews and Ratings.
Expand Down
3 changes: 1 addition & 2 deletions lang/en/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,20 @@
'type_attr_image' => 'Image',
'type_attr_file' => 'File',
'type_attr_geolocation' => 'Geolocation',
'type_attr_constructor' => 'Constructor',
'helptext' => 'Help text',
'helptext_help' => 'Description about this Attribute in adminpanel.',
'attribute_name_help' => 'This name will be displayed when the attribute is output.',
'attribute_introtext' => 'Description',
'attribute_introtext_help' => 'This description will be displayed when the attribute is displayed.',
'attrvalues' => 'Attribute values',
'attrvalues' => 'Attribute values',
'attrvalues_icon' => 'far fa-keyboard',
'attrvalues_help' => 'List of available values for the selected attribute.',
'to_list_attributes' => 'To the list of attributes',
'value' => 'Value',
'key' => 'Key',
'are_you_sure' => 'Are you sure?',
'deleted_irretrievably' => 'If you press the delete button, the item will be irretrievably deleted.',
'deleted' => 'Deleted.',
'canceled' => 'Cancelled.',
'additional_fields_main_product_tab' => 'Additional fields for the main product tab',
'caption' => 'Caption',
Expand Down
4 changes: 2 additions & 2 deletions lang/ru/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
'confirm_delete' => 'Подтвердить удаление',
'you_sure' => 'Вы уверены, что хотите удалить запись',
'with_id' => 'с ID',
'deleted' => 'Запись удалено.',
'deleted' => 'Запись удалена.',
'attributes' => 'Атрибуты',
'attributes_icon' => 'fas fa-paperclip',
'attributes_help' => 'Список дополнительных полей расширяющих возможности описания продуктов или заказов. Используются в качестве характеристик и/или фильтров.',
Expand Down Expand Up @@ -104,6 +104,7 @@
'type_attr_image' => 'Изображение',
'type_attr_file' => 'Файл',
'type_attr_geolocation' => 'Геолокация',
'type_attr_constructor' => 'Конструктор',
'helptext' => 'Справочный текст',
'helptext_help' => 'Описание этого атрибута в палитре администратора.',
'attribute_name_help' => 'Это название отображается при выводе атрибута.',
Expand All @@ -117,7 +118,6 @@
'key' => 'Ключ',
'are_you_sure' => 'Вы уверены?',
'deleted_irretrievably' => 'Если вы нажмете кнопку удалить, элемент будет удален безвозвратно.',
'deleted' => 'Удалено.',
'canceled' => 'Отменено.',
'additional_fields_main_product_tab' => 'Дополнительные поля для главного таба продукта',
'caption' => 'Подпись',
Expand Down
2 changes: 1 addition & 1 deletion lang/uk/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
'type_attr_image' => 'Зображення',
'type_attr_file' => 'Файл',
'type_attr_geolocation' => 'Геолокація',
'type_attr_constructor' => 'Конструктор',
'helptext' => 'Довідковий текст',
'helptext_help' => 'Опис цього атрибута в панелі адміністратора.',
'attribute_name_help' => 'Ця назва буде відображатись при виводі атрибута.',
Expand All @@ -117,7 +118,6 @@
'key' => 'Ключ',
'are_you_sure' => 'Ви впевнені?',
'deleted_irretrievably' => 'Якщо Ви натиснете кнопку видалити, елемент буде видалено безповоротно.',
'deleted' => 'Видалено.',
'canceled' => 'Скасовано.',
'additional_fields_main_product_tab' => 'Додаткові поля для головного таба продукта',
'caption' => 'Підпис',
Expand Down
13 changes: 12 additions & 1 deletion module/sCommerceModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Seiger\sCommerce\Models\sProduct;
use Seiger\sCommerce\Models\sProductTranslate;
use Seiger\sGallery\Facades\sGallery;
use Seiger\sGallery\Models\sGalleryField;
use Seiger\sGallery\Models\sGalleryModel;

if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE != 'true') die("No access");
if (!file_exists(EVO_CORE_PATH . 'custom/config/seiger/settings/sCommerce.php')) {
Expand Down Expand Up @@ -155,8 +157,17 @@
case "productDelete":
$product = sCommerce::getProduct((int)request()->input('i', 0));

if ($product) {
if ($product && isset($product->id) && (int)$product->id > 0) {
$sCommerceController->removeDirRecursive(MODX_BASE_PATH . 'assets/sgallery/product/' . $product->id);
$galleries = sGallery::all('product', $product->id);
if ($galleries->count()) {
foreach ($galleries as $gallery) {
if ($gallery) {
sGalleryField::where('key', $gallery->id)->delete();
$gallery->delete();
}
}
}

$product->categories()->sync([]);
$product->texts()->delete();
Expand Down
2 changes: 1 addition & 1 deletion src/Models/sAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class sAttribute extends Model
//const TYPE_ATTR_IMAGE = 11;
//const TYPE_ATTR_FILE = 12;
//const TYPE_ATTR_GEOLOCATION = 13;
//const TYPE_ATTR_DATERANGE = 14;
//const TYPE_ATTR_CONSTRUCTOR = 14;

/**
* Return list of type of input the attribute codes and labels
Expand Down

0 comments on commit b5c7561

Please sign in to comment.