diff --git a/Admin.php b/Admin.php
index 7d6ff9f..3c660c2 100644
--- a/Admin.php
+++ b/Admin.php
@@ -33,26 +33,24 @@ public function initConfigurationsFields()
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsSync'], 30, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsSku'], 60, 1);
+ add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsCategories'], 60, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsNames'], 60, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsDescriptions'], 60, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsImages'], 60, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsAttributes'], 60, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsPrices'], 70, 1);
- add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsTaxes'], 70, 1);
- add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsInventories'], 72, 1);
+ add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsInventories'], 71, 1);
+ add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsTaxes'], 73, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsDimensions'], 74, 1);
- add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsCategories'], 76, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsOther'], 79, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsProductsWithCharacteristics'], 80, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsCategories'], 80, 1);
- add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsCategoriesClassifierGroups'], 85, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsAttributes'], 90, 1);
- add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsAttributesClassifierProperties'], 90, 1);
add_filter('wc1c_configurations-update_form_load_fields', [$this, 'configurationsFieldsMediaLibrary'], 100, 1);
@@ -268,6 +266,33 @@ public function configurationsFieldsCategories(array $fields): array
'default' => 'no'
];
+ $fields['categories_classifier_groups_create'] =
+ [
+ 'title' => __('Creating categories from classifier groups', 'wc1c-main'),
+ 'type' => 'checkbox',
+ 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
+ 'description' => __('Categories are only created if they have not been created before. Also, if access to work with categories is allowed from the global settings.', 'wc1c-main'),
+ 'default' => 'no'
+ ];
+
+ $fields['categories_classifier_groups_create_assign_parent'] =
+ [
+ 'title' => __('Assign parent categories on creating', 'wc1c-main'),
+ 'type' => 'checkbox',
+ 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
+ 'description' => __('If there is a parent category in 1C, it will also be assigned in WooCommerce. The setting is triggered when a category is created.', 'wc1c-main'),
+ 'default' => 'yes'
+ ];
+
+ $fields['categories_classifier_groups_create_assign_description'] =
+ [
+ 'title' => __('Assign categories description on creating', 'wc1c-main'),
+ 'type' => 'checkbox',
+ 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
+ 'description' => __('When creating categories, descriptions will be filled in if category descriptions are present in 1C.', 'wc1c-main'),
+ 'default' => 'no'
+ ];
+
$fields['categories_update'] =
[
'title' => __('Updating categories', 'wc1c-main'),
@@ -282,6 +307,43 @@ public function configurationsFieldsCategories(array $fields): array
'default' => 'no'
];
+ $fields['categories_classifier_groups_update'] =
+ [
+ 'title' => __('Updating categories from classifier groups', 'wc1c-main'),
+ 'type' => 'checkbox',
+ 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
+ 'description' => __('If the category created earlier was linked to 1C data, then when you change any category data in 1C, the data will also change in WooCommerce.', 'wc1c-main'),
+ 'default' => 'no'
+ ];
+
+ $fields['categories_classifier_groups_update_parent'] =
+ [
+ 'title' => __('Update parent categories on updating', 'wc1c-main'),
+ 'type' => 'checkbox',
+ 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
+ 'description' => __('When enabled, parent categories will be updated when they are updated in 1C. The setting is triggered when a category is updated.', 'wc1c-main'),
+ 'default' => 'yes'
+ ];
+
+ $fields['categories_classifier_groups_update_name'] =
+ [
+ 'title' => __('Updating categories name', 'wc1c-main'),
+ 'type' => 'checkbox',
+ 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
+ 'description' => __('If the category was previously linked to 1C data, then when changing the name in 1C, the name will also change in WooCommerce.', 'wc1c-main'),
+ 'default' => 'no'
+ ];
+
+ $fields['categories_classifier_groups_update_description'] =
+ [
+ 'title' => __('Updating categories description', 'wc1c-main'),
+ 'type' => 'checkbox',
+ 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
+ 'description' => __('If the category was previously linked to 1C data, then when you change the description in 1C, the description will also change in WooCommerce.
+ It should be borne in mind that descriptions in 1C are not always stored. Therefore, you should not enable this function if the descriptions were filled out on the site.', 'wc1c-main'),
+ 'default' => 'no'
+ ];
+
$fields['categories_update_only_configuration'] =
[
'title' => __('Consider configuration when updating categories', 'wc1c-main'),
@@ -303,89 +365,6 @@ public function configurationsFieldsCategories(array $fields): array
return $fields;
}
- /**
- * Configuration fields: categories from classifier groups
- *
- * @param array $fields
- *
- * @return array
- */
- public function configurationsFieldsCategoriesClassifierGroups(array $fields): array
- {
- $fields['categories_classifier_groups'] =
- [
- 'title' => __('Categories: classifier groups', 'wc1c-main'),
- 'type' => 'title',
- 'description' => __('Create and update categories based on groups from the classifier.', 'wc1c-main'),
- ];
-
- $fields['categories_classifier_groups_create'] =
- [
- 'title' => __('Creating categories from classifier groups', 'wc1c-main'),
- 'type' => 'checkbox',
- 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
- 'description' => __('Categories are only created if they have not been created before. Also, if access to work with categories is allowed from the global settings.', 'wc1c-main'),
- 'default' => 'no'
- ];
-
- $fields['categories_classifier_groups_create_assign_parent'] =
- [
- 'title' => __('Assign parent categories on creating', 'wc1c-main'),
- 'type' => 'checkbox',
- 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
- 'description' => __('If there is a parent category in 1C, it will also be assigned in WooCommerce. The setting is triggered when a category is created.', 'wc1c-main'),
- 'default' => 'yes'
- ];
-
- $fields['categories_classifier_groups_create_assign_description'] =
- [
- 'title' => __('Assign categories description on creating', 'wc1c-main'),
- 'type' => 'checkbox',
- 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
- 'description' => __('When creating categories, descriptions will be filled in if category descriptions are present in 1C.', 'wc1c-main'),
- 'default' => 'no'
- ];
-
- $fields['categories_classifier_groups_update'] =
- [
- 'title' => __('Updating categories from classifier groups', 'wc1c-main'),
- 'type' => 'checkbox',
- 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
- 'description' => __('If the category created earlier was linked to 1C data, then when you change any category data in 1C, the data will also change in WooCommerce.', 'wc1c-main'),
- 'default' => 'no'
- ];
-
- $fields['categories_classifier_groups_update_parent'] =
- [
- 'title' => __('Update parent categories on updating', 'wc1c-main'),
- 'type' => 'checkbox',
- 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
- 'description' => __('When enabled, parent categories will be updated when they are updated in 1C. The setting is triggered when a category is updated.', 'wc1c-main'),
- 'default' => 'yes'
- ];
-
- $fields['categories_classifier_groups_update_name'] =
- [
- 'title' => __('Updating categories name', 'wc1c-main'),
- 'type' => 'checkbox',
- 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
- 'description' => __('If the category was previously linked to 1C data, then when changing the name in 1C, the name will also change in WooCommerce.', 'wc1c-main'),
- 'default' => 'no'
- ];
-
- $fields['categories_classifier_groups_update_description'] =
- [
- 'title' => __('Updating categories description', 'wc1c-main'),
- 'type' => 'checkbox',
- 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
- 'description' => __('If the category was previously linked to 1C data, then when you change the description in 1C, the description will also change in WooCommerce.
- It should be borne in mind that descriptions in 1C are not always stored. Therefore, you should not enable this function if the descriptions were filled out on the site.', 'wc1c-main'),
- 'default' => 'no'
- ];
-
- return $fields;
- }
-
/**
* Configuration fields: products with characteristics
*
@@ -477,68 +456,59 @@ public function configurationsFieldsAttributes(array $fields): array
'default' => 'no'
];
- $fields['attributes_update'] =
+ $fields['attributes_create_by_classifier_properties'] =
[
- 'title' => __('Updating attributes', 'wc1c-main'),
+ 'title' => __('Creating attributes from classifier properties', 'wc1c-main'),
'type' => 'checkbox',
'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
'description' => sprintf
(
'%s
%s',
- __('It will be allowed to update common attributes for products based on characteristics, properties and other data according to the other setting sections.', 'wc1c-main'),
- __('Attribute updating refers to adding product attribute values based on product characteristics, classifier properties, and other data specified in the settings. If you disable this feature, work will only occur with existing attribute values without updating attribute data. In some cases, updating refers to sorting and renaming the attributes themselves.', 'wc1c-main')
+ __('The creation will occur when processing the properties of the classifier. Creation occurs only if there is no attribute with the specified name or associated identifier.', 'wc1c-main'),
+ __('If disable the creation of attributes and create some attributes manually, it is possible to adding values to them.', 'wc1c-main')
),
'default' => 'no'
];
- return $fields;
- }
-
- /**
- * Configuration fields: attributes
- *
- * @param array $fields
- *
- * @return array
- */
- public function configurationsFieldsAttributesClassifierProperties(array $fields): array
- {
- $fields['attributes_classifier_properties'] =
+ $fields['attributes_update'] =
[
- 'title' => __('Attributes: classifier properties', 'wc1c-main'),
- 'type' => 'title',
+ 'title' => __('Updating attributes', 'wc1c-main'),
+ 'type' => 'checkbox',
+ 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
'description' => sprintf
(
- '%s %s',
- __('Adding and updating global attributes for products from classifier properties.', 'wc1c-main'),
- __('The properties are contained both in the classifier of the offer package and the product catalog.', 'wc1c-main')
+ '%s
%s',
+ __('It will be allowed to update common attributes for products based on characteristics, properties and other data according to the other setting sections.', 'wc1c-main'),
+ __('Attribute updating refers to adding product attribute values based on product characteristics, classifier properties, and other data specified in the settings. If you disable this feature, work will only occur with existing attribute values without updating attribute data. In some cases, updating refers to sorting and renaming the attributes themselves.', 'wc1c-main')
),
+ 'default' => 'no'
];
- $fields['attributes_create_by_classifier_properties'] =
+ $fields['attributes_values_by_classifier_properties'] =
[
- 'title' => __('Creating attributes from classifier properties', 'wc1c-main'),
+ 'title' => __('Updating attributes values from classifier properties', 'wc1c-main'),
'type' => 'checkbox',
'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
'description' => sprintf
(
'%s
%s',
- __('The creation will occur when processing the properties of the classifier. Creation occurs only if there is no attribute with the specified name or associated identifier.', 'wc1c-main'),
- __('If disable the creation of attributes and create some attributes manually, it is possible to adding values to them.', 'wc1c-main')
+ __('Adding product attribute values based on classifier property values.', 'wc1c-main'),
+ __('The value is added only if it is absent: by name.', 'wc1c-main')
),
'default' => 'no'
];
- $fields['attributes_values_by_classifier_properties'] =
+ $fields['attributes_values_by_product_properties'] =
[
- 'title' => __('Adding values to attributes from classifier properties', 'wc1c-main'),
+ 'title' => __('Adding values to attributes from product properties', 'wc1c-main'),
'type' => 'checkbox',
'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
'description' => sprintf
(
- '%s
%s',
- __('Adding product attribute values based on classifier property values.', 'wc1c-main'),
- __('The value is added only if it is absent: by name.', 'wc1c-main')
+ '%s
%s %s',
+ __('Classifier properties do not always contain values in the reference. When the setting is enabled, values will be added based on the values of the product properties.', 'wc1c-main'),
+ __('The value is added only if it is absent: by name.', 'wc1c-main'),
+ __('The value is added only if it is missing. If do not add a value, the attribute will be skipped.', 'wc1c-main')
),
'default' => 'no'
];
@@ -565,9 +535,33 @@ public function configurationsFieldsProductsCategories(array $fields): array
),
];
+ $products_categories_source_options =
+ [
+ 'no' => __('Do not use', 'wc1c-main'),
+ 'classifier_groups' => __('From classifier groups', 'wc1c-main'),
+ ];
+
+ $fields['products_categories_source'] =
+ [
+ 'title' => __('Source for categories', 'wc1c-main'),
+ 'type' => 'select',
+ 'description' => sprintf
+ (
+ '%s
%s - %s
%s - %s %s',
+ __('The setting works when creating and updating products (goods).', 'wc1c-main'),
+ __('Do not use', 'wc1c-main'),
+ __('Populating the categories data from CommerceML data will be skipped. If a product is updating, then its current categories will not be updated.', 'wc1c-main'),
+ __('From classifier groups', 'wc1c-main'),
+ __('The categories data will be filled in based on the classifier groups of the products (goods).', 'wc1c-main'),
+ __('To use this mode, need to configure the creation of categories based on classifier groups.', 'wc1c-main')
+ ),
+ 'default' => 'classifier_groups',
+ 'options' => $products_categories_source_options
+ ];
+
$fields['products_create_adding_category'] =
[
- 'title' => __('Assigning categories of the created product', 'wc1c-main'),
+ 'title' => __('Assigning categories of the creating products', 'wc1c-main'),
'type' => 'checkbox',
'label' => __('Check the box to enable this feature. Enabled by default.', 'wc1c-main'),
'description' => sprintf
@@ -593,14 +587,34 @@ public function configurationsFieldsProductsCategories(array $fields): array
'default' => 'yes'
];
- $fields['products_update_categories'] =
- [
- 'title' => __('Product categories update when requesting product updates', 'wc1c-main'),
- 'type' => 'checkbox',
- 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
- 'description' => __('If the setting is disabled, new categories will not be assigned to old products. Categories can be edited manually and the data will remain unchanged.', 'wc1c-main'),
- 'default' => 'no'
- ];
+ $products_update_categories_options =
+ [
+ 'no' => __('Do not update', 'wc1c-main'),
+ 'yes' => __('Update in any case', 'wc1c-main'),
+ 'add' => __('Add if not on the site and available in 1C', 'wc1c-main'),
+ 'yes_yes' => __('Update if present on the site and in 1C', 'wc1c-main'),
+ ];
+
+ $fields['products_update_categories'] =
+ [
+ 'title' => __('Categories updating when products updates', 'wc1c-main'),
+ 'default' => 'no',
+ 'type' => 'select',
+ 'description' => sprintf
+ (
+ '%s - %s
%s - %s
%s - %s
%s - %s
%s',
+ __('Do not update', 'wc1c-main'),
+ __('Categories updates will be skipped in any case.', 'wc1c-main'),
+ __('Update in any case', 'wc1c-main'),
+ __('Categories will be updated in any case. The same value will always be on the site and in 1C.', 'wc1c-main'),
+ __('Add if not on the site and available in 1C', 'wc1c-main'),
+ __('Existing categories will not be affected. There will be a filling of those missing on the site if they are available in 1C.', 'wc1c-main'),
+ __('Update if present on the site and in 1C', 'wc1c-main'),
+ __('Categories will be updated only if they are filled in 1C and on the site at the same time.', 'wc1c-main'),
+ __('The setting works when updating products (goods).', 'wc1c-main')
+ ),
+ 'options' => $products_update_categories_options
+ ];
$fields['products_update_categories_fill_parent'] =
[
@@ -869,7 +883,7 @@ public function configurationsFieldsProductsSku(array $fields): array
[
'title' => __('Products (goods): SKU', 'wc1c-main'),
'type' => 'title',
- 'description' => __('Sources and algorithms for filling out product SKU.', 'wc1c-main'),
+ 'description' => __('Sources and algorithms for filling out products SKU.', 'wc1c-main'),
];
$fields['products_create_adding_sku'] =
@@ -896,7 +910,7 @@ public function configurationsFieldsProductsSku(array $fields): array
$fields['products_update_sku'] =
[
- 'title' => __('Product SKU update when requesting product updates', 'wc1c-main'),
+ 'title' => __('SKU update when products updates', 'wc1c-main'),
'default' => 'no',
'type' => 'select',
'description' => sprintf
@@ -926,7 +940,7 @@ public function configurationsFieldsProductsSku(array $fields): array
$fields['products_sku_by_cml'] =
[
- 'title' => __('SKU based on CommerceML data', 'wc1c-main'),
+ 'title' => __('Source for SKUs', 'wc1c-main'),
'type' => 'select',
'description' => sprintf
(
@@ -949,9 +963,9 @@ public function configurationsFieldsProductsSku(array $fields): array
$fields['products_sku_from_requisites_name'] =
[
- 'title' => __('SKU based on CommerceML data: name for requisite', 'wc1c-main'),
+ 'title' => __('Source for SKUs: name for requisite', 'wc1c-main'),
'type' => 'text',
- 'description' => __('The name of the requisite of the product (goods) which contains a SKU of the product.', 'wc1c-main'),
+ 'description' => __('The name of the requisite of the products (goods) which contains a SKU of the product.', 'wc1c-main'),
'default' => '',
'css' => 'min-width: 370px;',
];
@@ -972,15 +986,15 @@ public function configurationsFieldsProductsNames(array $fields): array
[
'title' => __('Products (goods): names', 'wc1c-main'),
'type' => 'title',
- 'description' => __('Sources and algorithms for filling out product names.', 'wc1c-main'),
+ 'description' => __('Sources and algorithms for filling out products name.', 'wc1c-main'),
];
$fields['products_update_name'] =
[
- 'title' => __('Product name update when requesting product updates', 'wc1c-main'),
+ 'title' => __('Product name update when update products', 'wc1c-main'),
'type' => 'checkbox',
'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
- 'description' => __('When changing the product name in 1C, the data will be changed on the site.', 'wc1c-main'),
+ 'description' => __('When changing the products names in 1C, the data will be changed on the site.', 'wc1c-main'),
'default' => 'no'
];
@@ -994,7 +1008,7 @@ public function configurationsFieldsProductsNames(array $fields): array
$fields['products_names_by_cml'] =
[
- 'title' => __('Names based on CommerceML data', 'wc1c-main'),
+ 'title' => __('Source for product names', 'wc1c-main'),
'type' => 'select',
'description' => sprintf
(
@@ -1015,9 +1029,9 @@ public function configurationsFieldsProductsNames(array $fields): array
$fields['products_names_from_requisites_name'] =
[
- 'title' => __('Names based on CommerceML data: name for requisite', 'wc1c-main'),
+ 'title' => __('Source for product names: name for requisite', 'wc1c-main'),
'type' => 'text',
- 'description' => __('The name of the requisite of the product (goods) which contains a name of the product.', 'wc1c-main'),
+ 'description' => __('The name of the requisite of the products (goods) which contains a name of the product.', 'wc1c-main'),
'default' => '',
'css' => 'min-width: 370px;',
];
@@ -1043,7 +1057,7 @@ public function configurationsFieldsProductsDescriptions(array $fields): array
$fields['products_create_adding_description'] =
[
- 'title' => __('Filling the description of the created product', 'wc1c-main'),
+ 'title' => __('Filling the description of the created products', 'wc1c-main'),
'type' => 'checkbox',
'label' => __('Check the box to enable this feature. Disabled by default.', 'wc1c-main'),
'description' => sprintf
@@ -1066,7 +1080,7 @@ public function configurationsFieldsProductsDescriptions(array $fields): array
$fields['products_update_description'] =
[
- 'title' => __('Description update when requesting product updates', 'wc1c-main'),
+ 'title' => __('Description update when update products', 'wc1c-main'),
'default' => 'no',
'type' => 'select',
'description' => sprintf
@@ -1096,7 +1110,7 @@ public function configurationsFieldsProductsDescriptions(array $fields): array
$fields['products_descriptions_short_by_cml'] =
[
- 'title' => __('Descriptions based on CommerceML data: short', 'wc1c-main'),
+ 'title' => __('Source for descriptions', 'wc1c-main'),
'type' => 'select',
'description' => sprintf
(
@@ -1119,7 +1133,7 @@ public function configurationsFieldsProductsDescriptions(array $fields): array
$fields['products_descriptions_short_from_requisites_name'] =
[
- 'title' => __('Descriptions based on CommerceML data: short - name for requisite', 'wc1c-main'),
+ 'title' => __('Source for descriptions: name for requisite', 'wc1c-main'),
'type' => 'text',
'description' => __('The name of the requisite of the product (goods) which contains a short description of the product.', 'wc1c-main'),
'default' => '',
@@ -1128,7 +1142,7 @@ public function configurationsFieldsProductsDescriptions(array $fields): array
$fields['products_create_adding_description_full'] =
[
- 'title' => __('Filling a full description of the created product', 'wc1c-main'),
+ 'title' => __('Filling a full description of the created products', 'wc1c-main'),
'type' => 'checkbox',
'label' => __('Check the box to enable this feature. Disabled by default.', 'wc1c-main'),
'description' => sprintf
@@ -1143,7 +1157,7 @@ public function configurationsFieldsProductsDescriptions(array $fields): array
$fields['products_update_description_full'] =
[
- 'title' => __('Full description update when requesting product updates', 'wc1c-main'),
+ 'title' => __('Full description update when update products', 'wc1c-main'),
'default' => 'no',
'type' => 'select',
'description' => sprintf
@@ -1164,7 +1178,7 @@ public function configurationsFieldsProductsDescriptions(array $fields): array
$fields['products_descriptions_by_cml'] =
[
- 'title' => __('Descriptions based on CommerceML data: full', 'wc1c-main'),
+ 'title' => __('Source for full descriptions', 'wc1c-main'),
'type' => 'select',
'description' => sprintf
(
@@ -1187,7 +1201,7 @@ public function configurationsFieldsProductsDescriptions(array $fields): array
$fields['products_descriptions_from_requisites_name'] =
[
- 'title' => __('Descriptions based on CommerceML data: full - name for requisite', 'wc1c-main'),
+ 'title' => __('Source for full descriptions: name for requisite', 'wc1c-main'),
'type' => 'text',
'description' => __('The name of the requisite of the product (goods) which contains a full description of the product.', 'wc1c-main'),
'default' => '',
@@ -1231,21 +1245,6 @@ public function configurationsFieldsProductsAttributes(array $fields): array
'default' => 'no'
];
- $fields['attributes_values_by_product_properties'] =
- [
- 'title' => __('Adding values to attributes from product properties', 'wc1c-main'),
- 'type' => 'checkbox',
- 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
- 'description' => sprintf
- (
- '%s
%s %s',
- __('Classifier properties do not always contain values in the reference. When the setting is enabled, values will be added based on the values of the product properties.', 'wc1c-main'),
- __('The value is added only if it is absent: by name.', 'wc1c-main'),
- __('The value is added only if it is missing. If do not add a value, the attribute will be skipped.', 'wc1c-main')
- ),
- 'default' => 'no'
- ];
-
return $fields;
}
@@ -1358,7 +1357,7 @@ public function configurationsFieldsProductsImages(array $fields): array
$fields['products_create_adding_images'] =
[
- 'title' => __('Adding the images of the created product', 'wc1c-main'),
+ 'title' => __('Adding the images of the created products', 'wc1c-main'),
'type' => 'checkbox',
'label' => __('Check the box to enable this feature. Enabled by default.', 'wc1c-main'),
'description' => sprintf
@@ -1369,38 +1368,53 @@ public function configurationsFieldsProductsImages(array $fields): array
'default' => 'yes'
];
+ $products_update_images_options =
+ [
+ 'no' => __('Do not update', 'wc1c-main'),
+ 'yes' => __('Update in any case', 'wc1c-main'),
+ 'add' => __('Add if not on the site, but available in 1C', 'wc1c-main'),
+ 'yes_yes' => __('Update if present on the site and in 1C', 'wc1c-main'),
+ ];
+
$fields['products_update_images'] =
[
- 'title' => __('Product images update when requesting product updates', 'wc1c-main'),
- 'type' => 'checkbox',
- 'label' => __('Check the box if you want to enable this feature. Disabled by default.', 'wc1c-main'),
+ 'title' => __('Update images when update products', 'wc1c-main'),
+ 'default' => 'no',
+ 'type' => 'select',
'description' => sprintf
(
- '%s
%s',
- __('If the setting is disabled, new images will not be assigned to old products and the old ones will not be deleted either. In this case, you can edit images from WooCommerce.', 'wc1c-main'),
- __('The choice of a source for a brief images from 1C is in a separate settings block - Products (goods): images.', 'wc1c-main')
+ '%s - %s
%s - %s
%s - %s
%s - %s
%s',
+ __('Do not update', 'wc1c-main'),
+ __('Update images will be skipped in any case.', 'wc1c-main'),
+ __('Update in any case', 'wc1c-main'),
+ __('Images will be updated in any case. The same value will always be on the site and in 1C.', 'wc1c-main'),
+ __('Add if not on the site, but available in 1C', 'wc1c-main'),
+ __('Existing images will not be affected. There will be a filling of those missing on the site if they are available in 1C.', 'wc1c-main'),
+ __('Update if present on the site and in 1C', 'wc1c-main'),
+ __('Images will be updated only if they are filled in 1C and on the site at the same time.', 'wc1c-main'),
+ __('The setting works when updating products (goods).', 'wc1c-main')
),
- 'default' => 'no'
+ 'options' => $products_update_images_options
];
$fields['products_images_by_cml'] =
[
- 'title' => __('Images based on CommerceML files', 'wc1c-main'),
+ 'title' => __('Images based on CommerceML data', 'wc1c-main'),
'type' => 'checkbox',
- 'label' => __('Check the box to enable this feature. Disabled by default.', 'wc1c-main'),
+ 'label' => __('Check the box to enable this feature. Enabled by default.', 'wc1c-main'),
'description' => sprintf
(
'%s
%s %s',
__('When enabled, work with images based on CommerceML files will be allowed.', 'wc1c-main'),
- __('Available images in CommerceML files for products will be populated for future use.', 'wc1c-main'),
+ __('Available images in CommerceML data for products will be populated for future use.', 'wc1c-main'),
__('In this case, the image files themselves must first be added to the WordPress media library. If they are not included, their use will be skipped.', 'wc1c-main')
),
- 'default' => 'no'
+ 'default' => 'yes'
];
$fields['products_images_by_cml_max'] =
[
- 'title' => __('Images based on CommerceML files: maximum quantity', 'wc1c-main'),
+ 'title' => __('Images based on CommerceML data: maximum quantity', 'wc1c-main'),
'type' => 'text',
'description' => sprintf
(
@@ -1687,15 +1701,72 @@ public function configurationsFieldsProductsDimensions(array $fields): array
'description' => __('The main settings for filling in the dimensions of products (goods) according to data from 1C. Dimensions include: weight, length, width, height.', 'wc1c-main'),
];
- $fields['products_dimensions_by_requisites'] =
+ $fields['products_create_adding_dimensions'] =
[
- 'title' => __('Filling dimensions based on requisites', 'wc1c-main'),
+ 'title' => __('Filling the dimensions of the created product', 'wc1c-main'),
'type' => 'checkbox',
- 'label' => __('Check the box to enable this feature. Disabled by default.', 'wc1c-main'),
- 'description' => __('Filling in the dimensions will be performed from the given details of the products. For the setting to work, you must specify the correspondence of the details in the fields below.', 'wc1c-main'),
+ 'label' => __('Check the box to enable this feature. Enabled by default.', 'wc1c-main'),
+ 'description' => sprintf
+ (
+ '%s
%s',
+ __('The product dimensions will be added according to data from 1C. It is recommended to enable this feature.', 'wc1c-main'),
+ __('The setting works when creating products (goods).', 'wc1c-main')
+ ),
'default' => 'yes'
];
+ $products_update_dimensions_options =
+ [
+ 'no' => __('Do not update', 'wc1c-main'),
+ 'yes' => __('Update in any case', 'wc1c-main'),
+ 'add' => __('Add if not on the site and available in 1C', 'wc1c-main'),
+ 'yes_yes' => __('Update if present on the site and in 1C', 'wc1c-main'),
+ ];
+
+ $fields['products_update_dimensions'] =
+ [
+ 'title' => __('Dimensions update when products updates', 'wc1c-main'),
+ 'default' => 'no',
+ 'type' => 'select',
+ 'description' => sprintf
+ (
+ '%s - %s
%s - %s
%s - %s
%s - %s
%s',
+ __('Do not update', 'wc1c-main'),
+ __('Dimensions updates will be skipped in any case.', 'wc1c-main'),
+ __('Update in any case', 'wc1c-main'),
+ __('Dimensions will be updated in any case. The same value will always be on the site and in 1C.', 'wc1c-main'),
+ __('Add if not on the site, but available in 1C', 'wc1c-main'),
+ __('Existing dimensions will not be affected. There will be a filling of those missing on the site if they are available in 1C.', 'wc1c-main'),
+ __('Update if present on the site and in 1C', 'wc1c-main'),
+ __('Dimensions will be updated only if they are filled in 1C and on the site at the same time.', 'wc1c-main'),
+ __('The setting works when updating products (goods).', 'wc1c-main')
+ ),
+ 'options' => $products_update_dimensions_options
+ ];
+
+ $products_dimensions_source_options =
+ [
+ 'no' => __('Do not use', 'wc1c-main'),
+ 'yes_requisites' => __('From requisite with the specified name', 'wc1c-main'),
+ ];
+
+ $fields['products_dimensions_source'] =
+ [
+ 'title' => __('Source for dimensions', 'wc1c-main'),
+ 'type' => 'select',
+ 'description' => sprintf
+ (
+ '%s
%s - %s
%s - %s',
+ __('The setting works when creating and updating products (goods).', 'wc1c-main'),
+ __('Do not use', 'wc1c-main'),
+ __('Populating the dimensions data from CommerceML data will be skipped. If a product is updating, then its current dimensions will not be updated.', 'wc1c-main'),
+ __('From requisite with the specified name', 'wc1c-main'),
+ __('The dimensions data will be filled in based on the completed name of the requisite of the products (goods).', 'wc1c-main')
+ ),
+ 'default' => 'yes_requisites',
+ 'options' => $products_dimensions_source_options
+ ];
+
$fields['products_dimensions_by_requisites_weight_from_name'] =
[
'title' => __('Dimensions based on requisites: weight', 'wc1c-main'),
@@ -1772,7 +1843,7 @@ public function configurationsFieldsLogs(array $fields): array
[
'title' => __('Maximum files', 'wc1c-main'),
'type' => 'text',
- 'description' => __('Log files created daily. This option on the maximum number of stored files. By default saved of the logs are for the last 30 days.', 'wc1c-main'),
+ 'description' => __('Log files created daily. This option on the maximum number of stored files. By default saved of the logs are for the last 10 days.', 'wc1c-main'),
'default' => 10,
'css' => 'min-width: 20px;',
];
diff --git a/Core.php b/Core.php
index e95160c..194a1ae 100644
--- a/Core.php
+++ b/Core.php
@@ -51,23 +51,13 @@ class Core extends SchemaAbstract
*/
public $receiver;
- /**
- * @var string[]
- */
- public $offers_types =
- [
- 'offers',
- 'rests',
- 'prices',
- ];
-
/**
* Core constructor.
*/
public function __construct()
{
$this->setId('productscml');
- $this->setVersion('0.9.0');
+ $this->setVersion('0.10.0');
$this->setName(__('Products data exchange via CommerceML', 'wc1c-main'));
$this->setDescription(__('Creation and updating of products (goods) in WooCommerce according to data from 1C using the CommerceML protocol of various versions.', 'wc1c-main'));
@@ -172,22 +162,6 @@ public function getUploadDirectory(): string
return $this->upload_directory;
}
- /**
- * @return array string[]
- */
- public function getOffersTypes(): array
- {
- return $this->offers_types;
- }
-
- /**
- * @param string[] $offers_types
- */
- public function setOffersTypes(array $offers_types)
- {
- $this->offers_types = $offers_types;
- }
-
/**
* @param mixed $upload_directory
*/
@@ -402,11 +376,6 @@ public function processingClassifier(Reader $reader)
*/
public function processingClassifierGroups(ClassifierDataContract $classifier, Reader $reader)
{
- if($reader->getFiletype() !== 'import')
- {
- return;
- }
-
if(!$classifier->hasGroups())
{
$this->log()->info(__('Classifier groups is empty.', 'wc1c-main'));
@@ -720,11 +689,6 @@ public function processingClassifierGroups(ClassifierDataContract $classifier, R
*/
public function processingClassifierProperties(ClassifierDataContract $classifier, Reader $reader)
{
- if($reader->getFiletype() !== 'import' && $reader->getFiletype() !== 'offers')
- {
- return;
- }
-
if(!$classifier->hasProperties())
{
$this->log()->info(__('Classifier properties is empty.', 'wc1c-main'), ['filetype' => $reader->getFiletype()]);
@@ -958,27 +922,34 @@ public function processingClassifierItem(ClassifierDataContract $classifier, Rea
*/
public function processingCatalog(Reader $reader)
{
- if($reader->getFiletype() !== 'import')
+ if(false === $reader->isElement())
{
return;
}
- if(is_null($reader->catalog))
+ if($reader->nodeName === 'Каталог')
{
- $reader->catalog = new Catalog();
- }
+ if(is_null($reader->catalog))
+ {
+ $reader->catalog = new Catalog();
+ }
- if($reader->nodeName === 'Каталог' && $reader->isElement())
- {
$only_changes = $reader->xml_reader->getAttribute('СодержитТолькоИзменения') ?: true;
if($only_changes === 'false')
{
$only_changes = false;
}
$reader->catalog->setOnlyChanges($only_changes);
+
+ if(false === $only_changes)
+ {
+ $this->log()->notice(__('The time of the last full exchange has been set.', 'wc1c-main'));
+ $this->configuration()->addMetaData('_catalog_full_time', current_time('timestamp'), true);
+ $this->configuration()->saveMetaData();
+ }
}
- if($reader->parentNodeName === 'Каталог' && $reader->isElement())
+ if($reader->parentNodeName === 'Каталог')
{
switch($reader->nodeName)
{
@@ -1009,7 +980,7 @@ public function processingCatalog(Reader $reader)
/*
* Пропуск создания и обновления продуктов
*/
- if($reader->nodeName === 'Товары' && $reader->isElement()
+ if($reader->nodeName === 'Товары'
&& 'yes' !== $this->getOptions('products_update', 'no')
&& 'yes' !== $this->getOptions('products_create', 'no')
)
@@ -1018,7 +989,7 @@ public function processingCatalog(Reader $reader)
$reader->next();
}
- if($reader->parentNodeName === 'Товары' && $reader->nodeName === 'Товар' && $reader->isElement())
+ if($reader->parentNodeName === 'Товары' && $reader->nodeName === 'Товар')
{
$product_xml = new SimpleXMLElement($reader->xml_reader->readOuterXml());
@@ -1697,12 +1668,17 @@ public function assignProductsItemDescriptionsFull(ProductContract $internal_pro
*/
public function assignProductsItemCategories(ProductContract $internal_product, ProductDataContract $external_product, string $mode, Reader $reader): ProductContract
{
- if('create' === $mode && 'yes' !== $this->getOptions('products_create_adding_category', 'yes'))
+ if('create' === $mode && 'no' === $this->getOptions('products_create_adding_category', 'yes'))
{
return $internal_product;
}
- if('update' === $mode && 'yes' !== $this->getOptions('products_update_categories', 'no'))
+ if('create' === $mode && false === $external_product->hasClassifierGroups())
+ {
+ return $internal_product;
+ }
+
+ if('update' === $mode && 'no' === $this->getOptions('products_update_categories', 'no'))
{
return $internal_product;
}
@@ -1712,34 +1688,102 @@ public function assignProductsItemCategories(ProductContract $internal_product,
return $internal_product;
}
- if('create' === $mode && false === $external_product->hasClassifierGroups())
- {
- return $internal_product;
- }
+ $source = $this->getOptions('products_categories_source', 'classifier_groups');
- $cats = [];
+ if('no' === $source)
+ {
+ return $internal_product;
+ }
- if($external_product->hasClassifierGroups())
- {
- /** @var CategoriesStorageContract $categories_storage */
- $categories_storage = Storage::load('category');
+ $cats = [];
- foreach($external_product->getClassifierGroups() as $classifier_group)
- {
- $cat = $categories_storage->getByExternalId($classifier_group);
+ if(($source === 'classifier_groups') && $external_product->hasClassifierGroups())
+ {
+ $classifier_groups = $external_product->getClassifierGroups();
- if($cat instanceof Category)
- {
- $cats[] = $cat->getId();
- }
- }
- }
+ /** @var CategoriesStorageContract $categories_storage */
+ $categories_storage = Storage::load('category');
+
+ foreach($classifier_groups as $classifier_group)
+ {
+ $cat = $categories_storage->getByExternalId($classifier_group);
+
+ if($cat instanceof Category)
+ {
+ $cats[] = $cat->getId();
+ }
+ }
+ }
+
+ if('update' === $mode && 'add' === $this->getOptions('products_update_categories', 'no') && !empty($internal_product->get_category_ids()))
+ {
+ return $internal_product;
+ }
+
+ if('update' === $mode && empty($cats) && 'yes_yes' === $this->getOptions('products_update_categories', 'no') && empty($internal_product->get_category_ids()))
+ {
+ return $internal_product;
+ }
+
+ if
+ (
+ ('create' === $mode && $this->getOptions('products_create_adding_category_fill_parent', 'yes') === 'yes')
+ ||
+ ('update' === $mode && $this->getOptions('products_update_categories_fill_parent', 'yes') === 'yes')
+ )
+ {
+ $this->fillParentCategories($product_categories);
+ }
$internal_product->set_category_ids($cats);
return $internal_product;
}
+ /**
+ * Заполняет родительские категории у продукта
+ *
+ * @param $product_categories
+ *
+ * @return array
+ */
+ private function fillParentCategories(&$product_categories): array
+ {
+ if(empty($product_categories))
+ {
+ return $product_categories;
+ }
+
+ foreach($product_categories as $category_id)
+ {
+ $parents = $this->findParentCategories($category_id);
+
+ foreach($parents as $parent_id)
+ {
+ $key = array_search($parent_id, $product_categories, true);
+
+ if($key === false)
+ {
+ $product_categories[] = $parent_id;
+ }
+ }
+ }
+
+ return $product_categories;
+ }
+
+ /**
+ * Поиск всех родительских категорий
+ *
+ * @param int $category_id
+ *
+ * @return array
+ */
+ private function findParentCategories(int $category_id): array
+ {
+ return get_ancestors($category_id, 'product_cat');
+ }
+
/**
* Назначение данных продукта исходя из режима: статус налога
*
@@ -1827,6 +1871,11 @@ public function assignProductsItemTaxesClass(ProductContract $internal_product,
*/
public function assignProductsItemImages(ProductContract $internal_product, ProductDataContract $external_product, string $mode, Reader $reader): ProductContract
{
+ if('yes' !== $this->getOptions('products_images_by_cml', 'no'))
+ {
+ return $internal_product;
+ }
+
if('create' === $mode && false === $external_product->hasImages())
{
return $internal_product;
@@ -1842,29 +1891,35 @@ public function assignProductsItemImages(ProductContract $internal_product, Prod
return $internal_product;
}
- if('update' === $mode && 'yes' !== $this->getOptions('products_update_images', 'no'))
+ if('update' === $mode && 'no' === $this->getOptions('products_update_images', 'no'))
{
return $internal_product;
}
- if('yes' !== $this->getOptions('products_images_by_cml', 'no'))
+ $images_mode = $this->getOptions('products_update_images', 'no');
+ $images_max = $this->getOptions('products_images_by_cml_max', 10);
+ $external_images = $external_product->getImages();
+
+ if('update' === $mode && 'add' === $images_mode && !empty($internal_product->get_image_id()))
{
return $internal_product;
}
- $max_images = $this->getOptions('products_images_by_cml_max', 10);
+ if('update' === $mode && empty($external_images) && 'yes_yes' === $images_mode && empty($internal_product->get_image_id()))
+ {
+ return $internal_product;
+ }
/** @var ImagesStorageContract $images_storage */
$images_storage = Storage::load('image');
- $images = $external_product->getImages();
$gallery_image_ids = [];
- if(is_array($images))
+ if(is_array($external_images))
{
- foreach($images as $index => $image)
+ foreach($external_images as $index => $image)
{
- if($index >= $max_images)
+ if($index >= $images_max)
{
$this->log()->notice(__('The maximum possible number of images has been processed. The rest of the images are skip.', 'wc1c-main'));
break;
@@ -1923,7 +1978,19 @@ public function assignProductsItemImages(ProductContract $internal_product, Prod
*/
public function assignProductsItemDimensions(ProductContract $internal_product, ProductDataContract $external_product, string $mode, Reader $reader): ProductContract
{
- if('yes' !== $this->getOptions('products_dimensions_by_requisites', 'no'))
+ if('create' === $mode && 'no' === $this->getOptions('products_create_adding_dimensions', 'yes'))
+ {
+ return $internal_product;
+ }
+
+ if('update' === $mode && 'no' === $this->getOptions('products_update_dimensions', 'no'))
+ {
+ return $internal_product;
+ }
+
+ $dimensions_source = $this->getOptions('products_dimensions_source', 'yes_requisites');
+
+ if($dimensions_source === 'no')
{
return $internal_product;
}
@@ -1934,7 +2001,7 @@ public function assignProductsItemDimensions(ProductContract $internal_product,
$weight = '';
$weight_name = trim($this->getOptions('products_dimensions_by_requisites_weight_from_name', 'Вес'));
- if($weight_name !== '' && $external_product->hasRequisites($weight_name))
+ if($weight_name !== '' && $dimensions_source === 'yes_requisites' && $external_product->hasRequisites($weight_name))
{
$requisite_data = $external_product->getRequisites($weight_name);
if(!empty($requisite_data['value']))
@@ -1943,12 +2010,30 @@ public function assignProductsItemDimensions(ProductContract $internal_product,
}
}
- if(has_filter('wc1c_products_dimensions_by_requisites_weight'))
+ if(has_filter('wc1c_schema_productscml_products_dimensions_weight'))
{
- $weight = apply_filters('wc1c_products_dimensions_by_requisites_weight', $weight, $internal_product, $external_product, $mode, $reader, $this);
+ $weight = apply_filters('wc1c_schema_productscml_products_dimensions_weight', $weight, $internal_product, $external_product, $mode, $reader, $this);
}
- $internal_product->set_weight($weight);
+ if('update' === $mode && 'add' === $this->getOptions('products_update_dimensions', 'no') && empty($internal_product->get_weight()))
+ {
+ $internal_product->set_weight($weight);
+ }
+
+ if('update' === $mode && !empty($weight) && 'yes_yes' === $this->getOptions('products_update_dimensions', 'no') && !empty($internal_product->get_weight()))
+ {
+ $internal_product->set_weight($weight);
+ }
+
+ if('update' === $mode && 'yes' === $this->getOptions('products_update_dimensions', 'no'))
+ {
+ $internal_product->set_weight($weight);
+ }
+
+ if('create' === $mode)
+ {
+ $internal_product->set_weight($weight);
+ }
/**
* Длина
@@ -1956,7 +2041,7 @@ public function assignProductsItemDimensions(ProductContract $internal_product,
$length = '';
$length_name = trim($this->getOptions('products_dimensions_by_requisites_length_from_name', 'Длина'));
- if($length_name !== '' && $external_product->hasRequisites($length_name))
+ if($length_name !== '' && $dimensions_source === 'yes_requisites' && $external_product->hasRequisites($length_name))
{
$requisite_data = $external_product->getRequisites($length_name);
if(!empty($requisite_data['value']))
@@ -1965,12 +2050,30 @@ public function assignProductsItemDimensions(ProductContract $internal_product,
}
}
- if(has_filter('wc1c_products_dimensions_by_requisites_length'))
+ if(has_filter('wc1c_schema_productscml_products_dimensions_length'))
+ {
+ $length = apply_filters('wc1c_schema_productscml_products_dimensions_length', $length, $internal_product, $external_product, $mode, $reader, $this);
+ }
+
+ if('update' === $mode && 'add' === $this->getOptions('products_update_dimensions', 'no') && empty($internal_product->get_length()))
+ {
+ $internal_product->set_length($length);
+ }
+
+ if('update' === $mode && !empty($length) && 'yes_yes' === $this->getOptions('products_update_dimensions', 'no') && !empty($internal_product->get_length()))
+ {
+ $internal_product->set_length($length);
+ }
+
+ if('update' === $mode && 'yes' === $this->getOptions('products_update_dimensions', 'no'))
{
- $length = apply_filters('wc1c_products_dimensions_by_requisites_length', $length, $internal_product, $external_product, $mode, $reader, $this);
+ $internal_product->set_length($length);
}
- $internal_product->set_length($length);
+ if('create' === $mode)
+ {
+ $internal_product->set_length($length);
+ }
/**
* Ширина
@@ -1978,7 +2081,7 @@ public function assignProductsItemDimensions(ProductContract $internal_product,
$width = '';
$width_name = trim($this->getOptions('products_dimensions_by_requisites_width_from_name', 'Ширина'));
- if($width_name !== '' && $external_product->hasRequisites($width_name))
+ if($width_name !== '' && $dimensions_source === 'yes_requisites' && $external_product->hasRequisites($width_name))
{
$requisite_data = $external_product->getRequisites($width_name);
if(!empty($requisite_data['value']))
@@ -1987,12 +2090,30 @@ public function assignProductsItemDimensions(ProductContract $internal_product,
}
}
- if(has_filter('wc1c_products_dimensions_by_requisites_width'))
+ if(has_filter('wc1c_schema_productscml_products_dimensions_width'))
+ {
+ $width = apply_filters('wc1c_schema_productscml_products_dimensions_width', $width, $internal_product, $external_product, $mode, $reader, $this);
+ }
+
+ if('update' === $mode && 'add' === $this->getOptions('products_update_dimensions', 'no') && empty($internal_product->get_width()))
{
- $width = apply_filters('wc1c_products_dimensions_by_requisites_width', $width, $internal_product, $external_product, $mode, $reader, $this);
+ $internal_product->set_width($width);
}
- $internal_product->set_width($width);
+ if('update' === $mode && !empty($width) && 'yes_yes' === $this->getOptions('products_update_dimensions', 'no') && !empty($internal_product->get_width()))
+ {
+ $internal_product->set_width($width);
+ }
+
+ if('update' === $mode && 'yes' === $this->getOptions('products_update_dimensions', 'no'))
+ {
+ $internal_product->set_width($width);
+ }
+
+ if('create' === $mode)
+ {
+ $internal_product->set_width($width);
+ }
/**
* Высота
@@ -2000,7 +2121,7 @@ public function assignProductsItemDimensions(ProductContract $internal_product,
$height = '';
$height_name = trim($this->getOptions('products_dimensions_by_requisites_height_from_name', 'Высота'));
- if($height_name !== '' && $external_product->hasRequisites($height_name))
+ if($height_name !== '' && $dimensions_source === 'yes_requisites' && $external_product->hasRequisites($height_name))
{
$requisite_data = $external_product->getRequisites($height_name);
if(!empty($requisite_data['value']))
@@ -2009,12 +2130,30 @@ public function assignProductsItemDimensions(ProductContract $internal_product,
}
}
- if(has_filter('wc1c_products_dimensions_by_requisites_height'))
+ if(has_filter('wc1c_schema_productscml_products_dimensions_height'))
{
- $height = apply_filters('wc1c_products_dimensions_by_requisites_height', $height, $internal_product, $external_product, $mode, $reader, $this);
+ $height = apply_filters('wc1c_schema_productscml_products_dimensions_height', $height, $internal_product, $external_product, $mode, $reader, $this);
}
- $internal_product->set_height($height);
+ if('update' === $mode && 'add' === $this->getOptions('products_update_dimensions', 'no') && empty($internal_product->get_height()))
+ {
+ $internal_product->set_height($height);
+ }
+
+ if('update' === $mode && !empty($height) && 'yes_yes' === $this->getOptions('products_update_dimensions', 'no') && !empty($internal_product->get_height()))
+ {
+ $internal_product->set_height($height);
+ }
+
+ if('update' === $mode && 'yes' === $this->getOptions('products_update_dimensions', 'no'))
+ {
+ $internal_product->set_height($height);
+ }
+
+ if('create' === $mode)
+ {
+ $internal_product->set_height($height);
+ }
return $internal_product;
}
@@ -3157,6 +3296,8 @@ public function processingProductsItem(ProductDataContract $external_product, Re
return;
}
+ $this->log()->info(__('Product is found. Updating.', 'wc1c-main'));
+
/**
* Обновление существующих продуктов отключено
*/
@@ -3306,7 +3447,7 @@ public function processingOffersItem(ProductDataContract $external_offer, Reader
if(empty($internal_offer_id) && empty($external_offer->getCharacteristicId()))
{
- $this->log()->notice(__('Product not found. Offer update skipped.', 'wc1c-main'), ['offer' => $external_offer]);
+ $this->log()->notice(__('Product not found. Offer update skipped.', 'wc1c-main'), ['offer' => $external_offer->getData()]);
return;
}
@@ -3430,7 +3571,7 @@ public function processingOffersItem(ProductDataContract $external_offer, Reader
*/
public function processingOffers(Reader $reader)
{
- if(!in_array($reader->getFiletype(), $this->getOffersTypes(), true))
+ if(false === $reader->isElement())
{
return;
}
@@ -3440,7 +3581,7 @@ public function processingOffers(Reader $reader)
$reader->offers_package = new OffersPackage();
}
- if($reader->nodeName === 'ПакетПредложений' && $reader->isElement())
+ if($reader->nodeName === 'ПакетПредложений')
{
$only_changes = $reader->xml_reader->getAttribute('СодержитТолькоИзменения') ?: true;
if($only_changes === 'false')
@@ -3454,13 +3595,13 @@ public function processingOffers(Reader $reader)
$this->log()->debug(__('The offer package object contains only the changes.', 'wc1c-main'));
}
}
- elseif($reader->nodeName === 'ИзмененияПакетаПредложений' && $reader->isElement())
+ elseif($reader->nodeName === 'ИзмененияПакетаПредложений')
{
$this->log()->debug(__('The offer package object contains only the changes.', 'wc1c-main'));
$reader->offers_package->setOnlyChanges(true);
}
- if(($reader->parentNodeName === 'ПакетПредложений' || $reader->parentNodeName === 'ИзмененияПакетаПредложений') && $reader->isElement())
+ if(($reader->parentNodeName === 'ПакетПредложений' || $reader->parentNodeName === 'ИзмененияПакетаПредложений'))
{
switch($reader->nodeName)
{
@@ -3497,7 +3638,7 @@ public function processingOffers(Reader $reader)
}
}
- if($reader->nodeName === 'Предложения' && $reader->isElement())
+ if($reader->nodeName === 'Предложения')
{
if(false === $reader->offers_package->isOnlyChanges())
{
@@ -3522,7 +3663,7 @@ public function processingOffers(Reader $reader)
}
}
- if($reader->parentNodeName === 'Предложения' && $reader->nodeName === 'Предложение' && $reader->isElement())
+ if($reader->parentNodeName === 'Предложения' && $reader->nodeName === 'Предложение')
{
$offer_xml = new SimpleXMLElement($reader->xml_reader->readOuterXml());
diff --git a/Receiver.php b/Receiver.php
index bcf5d27..8676101 100644
--- a/Receiver.php
+++ b/Receiver.php
@@ -127,6 +127,16 @@ public function handlerCatalogModeComplete()
*/
public function handlerCatalogModeDeactivate()
{
+ if(isset($_GET['timestamp']))
+ {
+ $timestamp = (int)$_GET['timestamp'];
+
+ $this->core()->log()->notice(__('The time of the last full exchange has been set.', 'wc1c-main'));
+
+ $this->core()->configuration()->addMetaData('_catalog_full_time', $timestamp, true);
+ $this->core()->configuration()->saveMetaData();
+ }
+
$this->sendResponseByType('success');
}