|
@@ 848-854 (lines=7) @@
|
| 845 |
|
foreach ($categories as $categoryKey => $category) { |
| 846 |
|
$selectedCategory = $this->manager->getConnection()->executeQuery('SELECT `id` FROM s_plugin_connect_categories WHERE category_key = ? AND shop_id = ?', |
| 847 |
|
[$categoryKey, $shopId]); |
| 848 |
|
if (!($res = $selectedCategory->fetch())) { |
| 849 |
|
$this->manager->getConnection()->executeQuery('INSERT INTO s_plugin_connect_categories (category_key, label, shop_id) VALUES (?, ?, ?)', |
| 850 |
|
[$categoryKey, $category, $shopId]); |
| 851 |
|
$categoryId = (int) $this->manager->getConnection()->lastInsertId(); |
| 852 |
|
} else { |
| 853 |
|
$categoryId = (int) $res['id']; |
| 854 |
|
} |
| 855 |
|
$selectedProductToCategory = $this->manager->getConnection()->executeQuery('SELECT COUNT(*) FROM s_plugin_connect_product_to_categories WHERE connect_category_id = ? AND articleID = ?', |
| 856 |
|
[$categoryId, (int) $row['article_id']] |
| 857 |
|
)->fetchColumn(); |
|
@@ 936-943 (lines=8) @@
|
| 933 |
|
{ |
| 934 |
|
$selectedCategory = $this->manager->getConnection()->executeQuery('SELECT `id` FROM s_plugin_connect_categories WHERE category_key = ? AND shop_id IS NULL', |
| 935 |
|
[$categoryKey]); |
| 936 |
|
if (!($res = $selectedCategory->fetch())) { |
| 937 |
|
$this->manager->getConnection()->executeQuery('INSERT INTO s_plugin_connect_categories (category_key, label, shop_id) VALUES (?, ?, ?)', |
| 938 |
|
[$categoryKey, $category, $shopId]); |
| 939 |
|
$createdCategoryId = (int) $this->manager->getConnection()->lastInsertId(); |
| 940 |
|
$this->assignLocalCategories($createdCategoryId, $categoryKey); |
| 941 |
|
|
| 942 |
|
return $createdCategoryId; |
| 943 |
|
} |
| 944 |
|
|
| 945 |
|
$this->manager->getConnection()->executeQuery('UPDATE s_plugin_connect_categories SET shop_id = ? WHERE id = ?', |
| 946 |
|
[$shopId, $res['id']]); |