commit 60ba511804b931770a56623752227917a04063d5 Author: O K Date: Tue Sep 23 10:43:11 2025 +0300 first commit diff --git a/controllers/front/generate.php b/controllers/front/generate.php new file mode 100644 index 0000000..da9cc56 --- /dev/null +++ b/controllers/front/generate.php @@ -0,0 +1,93 @@ +context->link->getProductLink($product, null, null, null, $id_lang, $id_shop); + $all_links[] = $base_link; + + // Get links for combinations if they exist + if ($product->hasAttributes()) { + $combinations = $product->getAttributesResume($id_lang); + if ($combinations) { + foreach ($combinations as $combination) { + $combo_link = $this->context->link->getProductLink( + $product, + null, + null, + null, + $id_lang, + $id_shop, + $combination['id_product_attribute'], + false, + false, + true // Add attribute anchor + ); + $all_links[] = $combo_link; + } + } + } + } + } + } + + // Remove duplicates that might occur in complex shop setups and output JSON + echo json_encode(array_values(array_unique($all_links)), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); + exit; + } +} \ No newline at end of file diff --git a/productlinkchecker.php b/productlinkchecker.php new file mode 100644 index 0000000..3370d6d --- /dev/null +++ b/productlinkchecker.php @@ -0,0 +1,74 @@ +name = 'productlinkchecker'; + $this->tab = 'seo'; + $this->version = '1.0.0'; + $this->author = 'Panariga'; + $this->need_instance = 0; + $this->ps_versions_compliancy = ['min' => '1.7.6', 'max' => _PS_VERSION_]; + $this->bootstrap = true; + + parent::__construct(); + + $this->displayName = $this->l('Product Link Checker'); + $this->description = $this->l('Generates a JSON list of all product links for testing purposes.'); + + $this->confirmUninstall = $this->l('Are you sure you want to uninstall this module?'); + } + + /** + * Installation of the module. + */ + public function install() + { + if (!parent::install()) { + return false; + } + + // Generate and save a unique security token + $token = Tools::passwdGen(32); + Configuration::updateValue('PLC_SECURITY_TOKEN', $token); + + return true; + } + + /** + * Uninstallation of the module. + */ + public function uninstall() + { + Configuration::deleteByName('PLC_SECURITY_TOKEN'); + + return parent::uninstall(); + } + + /** + * Module configuration page. + */ + public function getContent() + { + $this->context->smarty->assign([ + 'security_token' => Configuration::get('PLC_SECURITY_TOKEN'), + 'shops' => Shop::getShops(true, null, true), + 'languages' => Language::getLanguages(true), + 'base_controller_url' => $this->context->link->getModuleLink($this->name, 'generate', [], true), + ]); + + return $this->display(__FILE__, 'views/templates/admin/configure.tpl'); + } +} \ No newline at end of file diff --git a/views/templates/admin/configure.tpl b/views/templates/admin/configure.tpl new file mode 100644 index 0000000..53529f6 --- /dev/null +++ b/views/templates/admin/configure.tpl @@ -0,0 +1,37 @@ +{* views/templates/admin/configure.tpl *} +
+
+ {l s='Product Link Checker Configuration' mod='productlinkchecker'} +
+ +
+

{l s='Your Security Token' mod='productlinkchecker'}

+

{l s='Use this token to access the link generator. Keep it secret!' mod='productlinkchecker'}

+

{$security_token|escape:'html':'UTF-8'}

+
+ + +
\ No newline at end of file