function getContent() { $is_one_dot_five = version_compare(_PS_VERSION_, '1.5', '>'); // Smarty $template_vars = array('id_tab' => Tools::getValue('id_tab'), 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'token' => Tools::getValue('token'), 'ebay_token' => Configuration::get('EBAY_SECURITY_TOKEN'), '_module_dir_' => _MODULE_DIR_, 'ebay_categories' => EbayCategoryConfiguration::getEbayCategories($this->ebay_profile->id), 'id_lang' => $this->context->cookie->id_lang, 'id_ebay_profile' => $this->ebay_profile->id, '_path' => $this->path, 'possible_attributes' => AttributeGroup::getAttributesGroups($this->context->cookie->id_lang), 'possible_features' => Feature::getFeatures($this->context->cookie->id_lang, true), 'date' => pSQL(date('Ymdhis')), 'conditions' => $this->_translatePSConditions(EbayCategoryConditionConfiguration::getPSConditions()), 'form_items_specifics' => EbaySynchronizer::getNbSynchronizableEbayCategoryCondition(), 'form_items_specifics_mixed' => EbaySynchronizer::getNbSynchronizableEbayCategoryConditionMixed(), 'isOneDotFive' => $is_one_dot_five); return $this->display('formItemsSpecifics.tpl', $template_vars); }
public function __construct($moduleInstance) { parent::__construct($moduleInstance); $productIdOptions = array(array('value' => 0, 'name' => 'Reference Code'), array('value' => 1, 'name' => 'EAN-13 or JAN barcode'), array('value' => 2, 'name' => 'UPC barcode')); $this->addSelectField('Product ID', 'map_id', $productIdOptions, true, $this->l('Select the product reference group you are using in your store')); $productManufacturerOptions = array(array('value' => 0, 'name' => 'Product Manufacturer'), array('value' => 1, 'name' => 'Product Supplier')); $this->addSelectField('Product Manufacturer', 'map_manufacturer', $productManufacturerOptions, true, $this->l('Select the field you are using to specify the manufacturer')); $productLinkOptions = array(array('value' => 0, 'name' => 'Use Product Link')); $this->addSelectField('Product Link', 'map_link', $productLinkOptions, true, $this->l('URL that leads to product. For upcoming features')); $productImageLinkOptions = array(array('value' => 0, 'name' => 'Cover Image'), array('value' => 1, 'name' => 'Random Image')); $this->addSelectField('Product Image', 'map_image', $productImageLinkOptions, true, $this->l('Choose if you want to use cover image or some random image from product\'s gallery')); $productCategoriesOptions = array(array('value' => 0, 'name' => 'Categories'), array('value' => 1, 'name' => 'Tags')); $this->addSelectField('Product Categories', 'map_category', $productCategoriesOptions, true, $this->l('Choose product tags if and only if no categories are set and instead product tags are in use')); $productPriceOptions = array(array('value' => 0, 'name' => 'Retail price with tax'), array('value' => 1, 'name' => 'Pre-tax retail price'), array('value' => 2, 'name' => 'Pre-tax wholesale price')); $this->addSelectField('Product Prices', 'map_price_with_vat', $productPriceOptions, true, $this->l('s option specify the product price that will be used in XML. This should be left to "Retail price with tax"')); $productMPNOptions = array(array('value' => 0, 'name' => 'Reference Code'), array('value' => 1, 'name' => 'EAN-13 or JAN barcode'), array('value' => 2, 'name' => 'UPC barcode'), array('value' => 3, 'name' => 'Supplier Reference')); $this->addSelectField('Product Manufacturer Reference Code', 'map_mpn', $productMPNOptions, true, $this->l('This option should reflect product\' manufacturer SKU')); $productISBNOptions = array(array('value' => 0, 'name' => 'Reference Code'), array('value' => 1, 'name' => 'EAN-13 or JAN barcode'), array('value' => 2, 'name' => 'UPC barcode'), array('value' => 3, 'name' => 'Supplier Reference')); $this->addSelectField('Product ISBN', 'map_isbn', $productISBNOptions, true, $this->l('This field will be used if you sell books in your store, to specify the ISBN of the book')); // Multiselect from attribute groups $default_lang = (int) \Configuration::get('PS_LANG_DEFAULT'); $productSizesOptions = array(); $productColorOptions = array(); $attributes = \AttributeGroup::getAttributesGroups($default_lang); foreach ($attributes as $attribute) { if ($attribute['is_color_group']) { $productColorOptions[] = array('value' => $attribute['id_attribute_group'], 'name' => $attribute['name']); } else { $productSizesOptions[] = array('value' => $attribute['id_attribute_group'], 'name' => $attribute['name']); } } $this->addMultiSelectField('Size Attributes', 'map_size', $productSizesOptions, true, $this->l('Choose the attributes that you use to specify product sizes. This field is used only if Fashion Store option is enabled'))->addMultiSelectField('Color Attributes', 'map_color', $productColorOptions, true, $this->l('Choose the attributes that you use to specify product colors. This field is used only if Fashion Store option is enabled')); }
public function __construct() { $this->name = 'topshop'; $this->tab = 'smart_shopping'; $this->version = '1.7.7'; $this->author = 'Roman Prokofyev'; $this->need_instance = 1; $this->display = 'view'; $this->bootstrap = true; //$this->ps_versions_compliancy = array('min' => '1.5.0.0', 'max' => '1.6'); $this->module_key = '2149d8638f786d69c1a762f1fbfb8124'; $this->custom_attributes = array('YAMARKET_COMPANY_NAME', 'YAMARKET_DELIVERY_PRICE', 'YAMARKET_SALES_NOTES', 'YAMARKET_COUNTRY_OF_ORIGIN', 'YAMARKET_EXPORT_TYPE', 'YAMARKET_MODEL_NAME', 'YAMARKET_DESC_TYPE', 'YAMARKET_DELIVERY_DELIVERY', 'YAMARKET_DELIVERY_PICKUP', 'YAMARKET_DELIVERY_STORE'); $this->country_of_origin_attr = Configuration::get('YAMARKET_COUNTRY_OF_ORIGIN'); $this->model_name_attr = Configuration::get('YAMARKET_MODEL_NAME'); parent::__construct(); $this->displayName = $this->l('Yandex Market'); if ($this->id && !Configuration::get('YAMARKET_COMPANY_NAME')) { $this->warning = $this->l('You have not yet set your Company Name'); } $this->description = $this->l('Provides price list export to Yandex Market'); $this->confirmUninstall = $this->l('Are you sure you want to delete your details ?'); // Variables fro price list $this->id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $this->proto_prefix = _PS_BASE_URL_; // Get groups $attribute_groups = AttributeGroup::getAttributesGroups($this->id_lang); $this->attibute_groups = array(); foreach ($attribute_groups as $group) { $this->attibute_groups[$group['id_attribute_group']] = $group['public_name']; } // Get categories $this->excluded_cats = explode(',', Configuration::get('TOPSHOP_EXCLUDED_CATS')); if (!$this->excluded_cats) { $this->excluded_cats = array(); } $all_cats = Category::getSimpleCategories($this->id_lang); $this->selected_cats = array(); $this->all_cats = array(); foreach ($all_cats as $cat) { $this->all_cats[] = $cat['id_category']; if (!in_array($cat['id_category'], $this->excluded_cats)) { $this->selected_cats[] = $cat['id_category']; } } //determine image type $this->image_type = 'large_default'; if (Tools::substr(_PS_VERSION_, 0, 5) == '1.5.0') { $this->image_type = 'large'; } }
function displayFormAttributes($obj, $languages, $defaultLanguage) { global $currentIndex, $cookie; $attributeJs = array(); $attributes = Attribute::getAttributes(intval($cookie->id_lang), true); foreach ($attributes as $k => $attribute) { $attributeJs[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; } $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $attributes_groups = AttributeGroup::getAttributesGroups(intval($cookie->id_lang)); $images = Image::getImages(intval($cookie->id_lang), $obj->id); if ($obj->id) { echo ' <table cellpadding="5"> <tr> <td colspan="2"><b>' . $this->l('Add or modify combinations for this product') . '</b> - <a href="index.php?tab=AdminCatalog&id_product=' . $obj->id . '&id_category=' . intval(Tools::getValue('id_category')) . '&attributegenerator&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/appearance.gif" alt="combinations_generator" class="middle" title="' . $this->l('Product combinations generator') . '" /> ' . $this->l('Product combinations generator') . '</a> </td> </tr> </table> <hr style="width:730px;"><br /> <table cellpadding="5" style="width:100%"> <tr> <td style="width:150px" valign="top">' . $this->l('Group:') . '</td> <td style="padding-bottom:5px;"><select name="attribute_group" id="attribute_group" style="width: 200px;" onchange="populate_attrs();">'; if (isset($attributes_groups)) { foreach ($attributes_groups as $k => $attribute_group) { if (isset($attributeJs[$attribute_group['id_attribute_group']])) { echo ' <option value="' . $attribute_group['id_attribute_group'] . '"> ' . htmlentities(stripslashes($attribute_group['name']), ENT_COMPAT, 'UTF-8') . ' </option>'; } } } echo ' </select></td> </tr> <tr> <td style="width:150px" valign="top">' . $this->l('Attribute:') . '</td> <td style="padding-bottom:5px;"><select name="attribute" id="attribute" style="width: 200px;"> <option value="0">---</option> </select> <script type="text/javascript" language="javascript">populate_attrs();</script> </td> </tr> <tr> <td style="width:150px" valign="top"> <input style="width: 140px; margin-bottom: 10px;" type="button" value="' . $this->l('Add') . '" class="button" onclick="add_attr();"/><br /> <input style="width: 140px;" type="button" value="' . $this->l('Delete') . '" class="button" onclick="del_attr()"/></td> <td align="left"> <select id="product_att_list" name="attribute_combinaison_list[]" multiple="multiple" size="4" style="width: 320px;"></select> </td> </tr> <tr><td colspan="2"><hr style="width:730px;"></td></tr> <tr> <td style="width:150px">' . $this->l('Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" id="attribute_reference" name="attribute_reference" value="" style="width: 130px; margin-right: 44px;" /> ' . $this->l('EAN13:') . '<input size="55" maxlength="13" type="text" id="attribute_ean13" name="attribute_ean13" value="" style="width: 110px; margin-left: 10px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#<span class="hint-pointer"> </span></span> </td> </tr> <tr> <td style="width:150px">' . $this->l('Supplier Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" id="attribute_supplier_reference" name="attribute_supplier_reference" value="" style="width: 130px; margin-right: 44px;" /> ' . $this->l('Location:') . '<input size="55" type="text" id="attribute_location" name="attribute_location" value="" style="width: 101px; margin-left: 10px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#<span class="hint-pointer"> </span></span> </td> </tr> <tr><td colspan="2"><hr style="width:730px;"></td></tr> <tr> <td style="width:150px">' . $this->l('Wholesale price:') . '</td> <td style="padding-bottom:5px;">' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input type="text" size="6" name="attribute_wholesale_price" id="attribute_wholesale_price" value="0.00" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' (' . $this->l('overrides Wholesale price on Information tab') . ')</td> </tr> <tr> <td style="width:150px">' . $this->l('Impact on price:') . '</td> <td colspan="2" style="padding-bottom:5px;"> <select name="attribute_price_impact" id="attribute_price_impact" style="width: 140px;" onchange="check_impact();"> <option value="0">' . $this->l('None') . '</option> <option value="1">' . $this->l('Increase') . '</option> <option value="-1">' . $this->l('Reduction') . '</option> </select> <sup>*</sup> <span id="span_impact"> ' . $this->l('of') . ' ' . ($currency->format == 1 ? $currency->sign . ' ' : '') . ' <input type="text" size="6" name="attribute_price" id="attribute_price" value="0.00" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');"/>' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' </span> </td> </tr> <tr> <td style="width:150px">' . $this->l('Impact on weight:') . '</td> <td colspan="2" style="padding-bottom:5px;"><select name="attribute_weight_impact" id="attribute_weight_impact" style="width: 140px;" onchange="check_weight_impact();"> <option value="0">' . $this->l('None') . '</option> <option value="1">' . $this->l('Increase') . '</option> <option value="-1">' . $this->l('Reduction') . '</option> </select> <span id="span_weight_impact"> ' . $this->l('of') . ' <input type="text" size="6" name="attribute_weight" id="attribute_weight" value="0.00" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . '</span></td> </tr> <tr> <td style="width:150px">' . $this->l('Eco-tax:') . '</td> <td style="padding-bottom:5px;">' . ($currency->format == 1 ? $currency->sign . ' ' : '') . '<input type="text" size="3" name="attribute_ecotax" id="attribute_ecotax" value="0.00" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format == 2 ? ' ' . $currency->sign : '') . ' (' . $this->l('overrides Eco-tax on Information tab') . ')</td> </tr> <tr> <td style="width:150px">' . $this->l('Quantity:') . '</td> <td style="padding-bottom:5px;"><input type="text" size="3" name="attribute_quantity" id="attribute_quantity" value="1" /> (' . $this->l('overrides Quantity on Information tab') . ')</td> </tr> <tr> <td colspan="2"><sup>*</sup> ' . $this->l('included tax') . '</td> </tr> <tr><td colspan="2"><hr style="width:730px;"></td></tr> <tr> <td style="width:150px">' . $this->l('Image:') . '</td> <td style="padding-bottom:5px;"> <ul id="id_image_attr">'; $i = 0; $imageType = ImageType::getByNameNType('small', 'products'); $imageWidth = (isset($imageType['width']) ? intval($imageType['width']) : 64) + 25; foreach ($images as $image) { echo '<li style="float: left; width: ' . $imageWidth . 'px;"><input type="checkbox" name="id_image_attr[]" value="' . intval($image['id_image']) . '" id="id_image_attr_' . intval($image['id_image']) . '" /> <label for="id_image_attr_' . intval($image['id_image']) . '" style="float: none;"><img src="../img/p/' . $obj->id . '-' . $image['id_image'] . '-small.jpg" alt="' . htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8') . '" title="' . htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8') . '" /></label></li>'; ++$i; } echo '</ul> <img id="pic" alt="" title="" style="display: none; width: 100px; height: 100px; float: left; border: 1px dashed #BBB; margin-left: 20px;" /> </td> </tr> <tr> <td style="width:150px">' . $this->l('Default:') . '<br /><br /></td> <td style="padding-bottom:5px;"> <input type="checkbox" name="attribute_default" id="attribute_default" value="1" /> ' . $this->l('Make the default combination for this product') . '<br /><br /> </td> </tr> <tr> <td style="width:150px"> </td> <td style="padding-bottom:5px;"> <span style="float: left;"><input type="submit" name="submitProductAttribute" id="submitProductAttribute" value="' . $this->l('Add this combination') . '" class="button" onclick="attr_selectall();" /> </span> <span id="ResetSpan" style="float: left; margin-left: 8px; display: none;"> <input type="reset" name="ResetBtn" id="ResetBtn" onclick="if (!confirm(\'' . $this->l('Are you sure you want to cancel?', __CLASS__, true, false) . '\')) return; init_elems(); getE(\'submitProductAttribute\').value = \'' . $this->l('Add this attributes group', __CLASS__, true) . '\'; getE(\'id_product_attribute\').value = -1; openCloseLayer(\'ResetSpan\');" class="button" value="' . $this->l('Cancel modification') . '" /></span><span style="clear: both;"></span> </td> </tr> <tr><td colspan="2"><hr style="width:730px;"></td></tr> <tr> <td colspan="2"> <br /> <table border="0" cellpadding="0" cellspacing="0" class="table" style="width: 600px;"> <tr> <th>' . $this->l('Attributes') . '</th> <th>' . $this->l('Price') . '</th> <th>' . $this->l('Weight') . '</th> <th>' . $this->l('Reference') . '</th> <th>' . $this->l('EAN13') . '</th> <th class="center">' . $this->l('Quantity') . '</th> <th class="center">' . $this->l('Actions') . '</th> </tr>'; if ($obj->id) { /* Build attributes combinaisons */ $combinaisons = $obj->getAttributeCombinaisons(intval($cookie->id_lang)); $groups = array(); if (is_array($combinaisons)) { $combinationImages = $obj->getCombinationImages(intval($cookie->id_lang)); foreach ($combinaisons as $k => $combinaison) { $combArray[$combinaison['id_product_attribute']]['wholesale_price'] = $combinaison['wholesale_price']; $combArray[$combinaison['id_product_attribute']]['price'] = $combinaison['price']; $combArray[$combinaison['id_product_attribute']]['weight'] = $combinaison['weight']; $combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference']; $combArray[$combinaison['id_product_attribute']]['supplier_reference'] = $combinaison['supplier_reference']; $combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13']; $combArray[$combinaison['id_product_attribute']]['location'] = $combinaison['location']; $combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity']; $combArray[$combinaison['id_product_attribute']]['id_image'] = isset($combinationImages[$combinaison['id_product_attribute']][0]['id_image']) ? $combinationImages[$combinaison['id_product_attribute']][0]['id_image'] : 0; $combArray[$combinaison['id_product_attribute']]['default_on'] = $combinaison['default_on']; $combArray[$combinaison['id_product_attribute']]['ecotax'] = $combinaison['ecotax']; $combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']); if ($combinaison['is_color_group']) { $groups[$combinaison['id_attribute_group']] = $combinaison['group_name']; } } } $irow = 0; if (isset($combArray)) { foreach ($combArray as $id_product_attribute => $product_attribute) { $list = ''; $jsList = ''; foreach ($product_attribute['attributes'] as $attribute) { $list .= addslashes(htmlspecialchars($attribute[0])) . ' - ' . addslashes(htmlspecialchars($attribute[1])) . ', '; $jsList .= '\'' . addslashes(htmlspecialchars($attribute[0])) . ' : ' . addslashes(htmlspecialchars($attribute[1])) . '\', \'' . $attribute[2] . '\', '; } $list = rtrim($list, ', '); $jsList = rtrim($jsList, ', '); $attrImage = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false; echo ' <tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ($product_attribute['default_on'] ? ' style="background-color:#D1EAEF"' : '') . '> <td>' . stripslashes($list) . '</td> <td class="right">' . ($currency->format == 1 ? $currency->sign . ' ' : '') . $product_attribute['price'] . ($currency->format == 2 ? ' ' . $currency->sign : '') . '</td> <td class="right">' . $product_attribute['weight'] . Configuration::get('PS_WEIGHT_UNIT') . '</td> <td class="right">' . $product_attribute['reference'] . '</td> <td class="right">' . $product_attribute['ean13'] . '</td> <td class="center">' . $product_attribute['quantity'] . '</td> <td class="center"> <a style="cursor: pointer;"> <img src="../img/admin/edit.gif" alt="' . $this->l('Modify this combination') . '" onclick="javascript:fillCombinaison(\'' . $product_attribute['wholesale_price'] . '\', \'' . $product_attribute['price'] . '\', \'' . $product_attribute['weight'] . '\', \'' . $product_attribute['reference'] . '\', \'' . $product_attribute['supplier_reference'] . '\', \'' . $product_attribute['ean13'] . '\', \'' . $product_attribute['quantity'] . '\', \'' . ($attrImage ? $attrImage->id : 0) . '\', Array(' . $jsList . '), \'' . $id_product_attribute . '\', \'' . $product_attribute['default_on'] . '\', \'' . $product_attribute['ecotax'] . '\', \'' . $product_attribute['location'] . '\');" /></a> <a href="' . $currentIndex . '&deleteProductAttribute&id_product_attribute=' . $id_product_attribute . '&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this combination') . '" /></a></td> </tr>'; } } else { echo '<tr><td colspan="7" align="center"><i>' . $this->l('No combination yet') . '.</i></td></tr>'; } } echo ' </table> <br />' . $this->l('The row in blue is the default combination.') . ' <br /> ' . $this->l('A default combination must be designated for each product.') . ' </td> </tr> </table> <script type="text/javascript"> var impact = getE(\'attribute_price_impact\'); var impact2 = getE(\'attribute_weight_impact\'); var s_attr_group = document.getElementById(\'span_new_group\'); var s_attr_name = document.getElementById(\'span_new_attr\'); var s_impact = document.getElementById(\'span_impact\'); var s_impact2 = document.getElementById(\'span_weight_impact\'); init_elems(); </script> <hr style="width:730px;"> <table cellpadding="5"> <tr> <td class="col-left"><b>' . $this->l('Color picker:') . '</b></td> <td style="padding-bottom:5px;"> <select name="id_color_default"> <option value="0">' . $this->l('Do not display') . '</option>'; foreach ($attributes_groups as $k => $attribute_group) { if (isset($groups[$attribute_group['id_attribute_group']])) { echo '<option value="' . intval($attribute_group['id_attribute_group']) . '" ' . (intval($attribute_group['id_attribute_group']) == intval($obj->id_color_default) ? 'selected="selected"' : '') . '>' . htmlentities(stripslashes($attribute_group['name']), ENT_COMPAT, 'UTF-8') . '</option>'; } } echo ' </select> <input type="submit" value="' . $this->l('OK') . '" name="submitAdd' . $this->table . '" class="button" /> <a href="index.php?tab=AdminAttributesGroups&token=' . Tools::getAdminToken('AdminAttributesGroups' . intval(Tab::getIdFromClassName('AdminAttributesGroups')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/asterisk.gif" alt="" /> ' . $this->l('Color attribute management') . '</a> <p >' . $this->l('Active the color choice by selecting a color attribute group.') . '</p> </td> </tr> </table>'; } else { echo '<b>' . $this->l('You must save this product before adding combinations') . '.</b>'; } }
public function attributeImport() { global $cookie; $defaultLanguage = Configuration::get('PS_LANG_DEFAULT'); $groups = array(); foreach (AttributeGroup::getAttributesGroups($defaultLanguage) as $group) { $groups[$group['name']] = (int) $group['id_attribute_group']; } $attributes = array(); foreach (Attribute::getAttributes($defaultLanguage) as $attribute) { $attributes[$attribute['attribute_group'] . '_' . $attribute['name']] = (int) $attribute['id_attribute']; } $this->receiveTab(); $handle = $this->openCsvFile(); $fsep = (is_null(Tools::getValue('multiple_value_separator')) or trim(Tools::getValue('multiple_value_separator')) == '') ? ',' : Tools::getValue('multiple_value_separator'); self::setLocale(); for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, Tools::getValue('separator')); $current_line++) { if (Tools::getValue('convert')) { $line = $this->utf8_encode_array($line); } $info = self::getMaskedRow($line); $info = array_map('trim', $info); self::setDefaultValues($info); $product = new Product((int) $info['id_product'], false, $defaultLanguage); $id_image = null; if (isset($info['image_url']) && $info['image_url']) { $productHasImages = (bool) Image::getImages((int) $cookie->id_lang, (int) $product->id); $url = $info['image_url']; $image = new Image(); $image->id_product = (int) $product->id; $image->position = Image::getHighestPosition($product->id) + 1; $image->cover = !$productHasImages ? true : false; $image->legend = self::createMultiLangField($product->name); if (($fieldError = $image->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $image->add()) { if (!self::copyImg($product->id, $image->id, $url)) { $this->_warnings[] = Tools::displayError('Error copying image: ') . $url; } else { $id_image = array($image->id); } } else { $this->_warnings[] = $image->legend[$defaultLanguageId] . (isset($image->id_product) ? ' (' . $image->id_product . ')' : '') . ' ' . Tools::displayError('Cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } elseif (isset($info['image_position']) && $info['image_position']) { $images = $product->getImages($defaultLanguage); if ($images) { foreach ($images as $row) { if ($row['position'] == (int) $info['image_position']) { $id_image = array($row['id_image']); break; } } } if (!$id_image) { $this->_warnings[] = sprintf(Tools::displayError('No image found for combination with id_product = %s and image position = %s.'), $product->id, (int) $info['image_position']); } } $id_product_attribute = $product->addProductAttribute((double) $info['price'], (double) $info['weight'], 0, (double) $info['ecotax'], (int) $info['quantity'], $id_image, strval($info['reference']), strval($info['supplier_reference']), strval($info['ean13']), (int) $info['default_on'], strval($info['upc'])); foreach (explode($fsep, $info['options']) as $option) { list($group, $attribute) = array_map('trim', explode(':', $option)); if (!isset($groups[$group])) { $obj = new AttributeGroup(); $obj->is_color_group = false; $obj->name[$defaultLanguage] = $group; $obj->public_name[$defaultLanguage] = $group; if (($fieldError = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { $obj->add(); $groups[$group] = $obj->id; } else { $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : ''); } } if (!isset($attributes[$group . '_' . $attribute])) { $obj = new Attribute(); $obj->id_attribute_group = $groups[$group]; $obj->name[$defaultLanguage] = str_replace('\\n', '', str_replace('\\r', '', $attribute)); if (($fieldError = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { $obj->add(); $attributes[$group . '_' . $attribute] = $obj->id; } else { $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : ''); } } Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'product_attribute_combination (id_attribute, id_product_attribute) VALUES (' . (int) $attributes[$group . '_' . $attribute] . ',' . (int) $id_product_attribute . ')'); } } $this->closeCsvFile($handle); }
public function initContent() { if (!Combination::isFeatureActive()) { $url = '<a href="index.php?tab=AdminPerformance&token=' . Tools::getAdminTokenLite('AdminPerformance') . '#featuresDetachables">' . $this->trans('Performance', array(), 'Admin.Global') . '</a>'; $this->displayWarning(sprintf($this->trans('This feature has been disabled. You can activate it here: %s.', array('%s' => $url), 'Admin.Catalog.Notification'))); return; } // Init toolbar $this->initPageHeaderToolbar(); $this->initGroupTable(); $attributes = Attribute::getAttributes(Context::getContext()->language->id, true); $attribute_js = array(); foreach ($attributes as $k => $attribute) { $attribute_js[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; } $attribute_groups = AttributeGroup::getAttributesGroups($this->context->language->id); $this->product = new Product((int) Tools::getValue('id_product')); $this->context->smarty->assign(array('tax_rates' => $this->product->getTaxesRate(), 'generate' => isset($_POST['generate']) && !count($this->errors), 'combinations_size' => count($this->combinations), 'product_name' => $this->product->name[$this->context->language->id], 'product_reference' => $this->product->reference, 'url_generator' => self::$currentIndex . '&id_product=' . (int) Tools::getValue('id_product') . '&attributegenerator&token=' . Tools::getValue('token'), 'attribute_groups' => $attribute_groups, 'attribute_js' => $attribute_js, 'toolbar_btn' => $this->toolbar_btn, 'toolbar_scroll' => true, 'show_page_header_toolbar' => $this->show_page_header_toolbar, 'page_header_toolbar_title' => $this->page_header_toolbar_title, 'page_header_toolbar_btn' => $this->page_header_toolbar_btn)); }
public function initFormAttributes($product) { $data = $this->createTemplate($this->tpl_form); if (!Combination::isFeatureActive()) { $this->displayWarning($this->l('This feature has been disabled. ') . ' <a href="index.php?tab=AdminPerformance&token=' . Tools::getAdminTokenLite('AdminPerformance') . '#featuresDetachables">' . $this->l('Performances') . '</a>'); } else { if (Validate::isLoadedObject($product)) { if ($this->product_exists_in_shop) { if ($product->is_virtual) { $data->assign('product', $product); $this->displayWarning($this->l('A virtual product cannot have combinations.')); } else { $attribute_js = array(); $attributes = Attribute::getAttributes($this->context->language->id, true); foreach ($attributes as $k => $attribute) { $attribute_js[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; } $currency = $this->context->currency; $data->assign('attributeJs', $attribute_js); $data->assign('attributes_groups', AttributeGroup::getAttributesGroups($this->context->language->id)); $data->assign('currency', $currency); $images = Image::getImages($this->context->language->id, $product->id); $data->assign('tax_exclude_option', Tax::excludeTaxeOption()); $data->assign('ps_weight_unit', Configuration::get('PS_WEIGHT_UNIT')); $data->assign('ps_use_ecotax', Configuration::get('PS_USE_ECOTAX')); $data->assign('field_value_unity', $this->getFieldValue($product, 'unity')); $data->assign('reasons', $reasons = StockMvtReason::getStockMvtReasons($this->context->language->id)); $data->assign('ps_stock_mvt_reason_default', $ps_stock_mvt_reason_default = Configuration::get('PS_STOCK_MVT_REASON_DEFAULT')); $data->assign('minimal_quantity', $this->getFieldValue($product, 'minimal_quantity') ? $this->getFieldValue($product, 'minimal_quantity') : 1); $data->assign('available_date', $this->getFieldValue($product, 'available_date') != 0 ? stripslashes(htmlentities($this->getFieldValue($product, 'available_date'), $this->context->language->id)) : '0000-00-00'); $i = 0; $type = ImageType::getByNameNType('%', 'products', 'height'); if (isset($type['name'])) { $data->assign('imageType', $type['name']); } else { $data->assign('imageType', 'small_default'); } $data->assign('imageWidth', (isset($image_type['width']) ? (int) $image_type['width'] : 64) + 25); foreach ($images as $k => $image) { $images[$k]['obj'] = new Image($image['id_image']); ++$i; } $data->assign('images', $images); $data->assign($this->tpl_form_vars); $data->assign(array('list' => $this->renderListAttributes($product, $currency), 'product' => $product, 'id_category' => $product->getDefaultCategory(), 'token_generator' => Tools::getAdminTokenLite('AdminAttributeGenerator'), 'combination_exists' => Shop::isFeatureActive() && Shop::getContextShopGroup()->share_stock && count(AttributeGroup::getAttributesGroups($this->context->language->id)) > 0 && $product->hasAttributes())); } } else { $this->displayWarning($this->l('You must save the product in this shop before adding combinations.')); } } else { $data->assign('product', $product); $this->displayWarning($this->l('You must save this product before adding combinations.')); } } $this->tpl_form_vars['custom_form'] = $data->fetch(); }
public function initContent() { if (!Combination::isFeatureActive()) { $this->displayWarning($this->l('This feature has been disabled, you can activate it at:') . ' <a href="index.php?tab=AdminPerformance&token=' . Tools::getAdminTokenLite('AdminPerformance') . '#featuresDetachables">' . $this->l('Performance') . '</a>'); return; } // Init toolbar $this->initToolbarTitle(); $this->initToolbar(); $this->initGroupTable(); $js_attributes = AdminAttributeGeneratorController::displayAndReturnAttributeJs(); $attribute_groups = AttributeGroup::getAttributesGroups($this->context->language->id); $this->product = new Product((int) Tools::getValue('id_product')); $this->context->smarty->assign(array('tax_rates' => $this->product->getTaxesRate(), 'generate' => isset($_POST['generate']) && !count($this->errors), 'combinations_size' => count($this->combinations), 'product_name' => $this->product->name[$this->context->language->id], 'product_reference' => $this->product->reference, 'url_generator' => self::$currentIndex . '&id_product=' . (int) Tools::getValue('id_product') . '&attributegenerator&token=' . Tools::getValue('token'), 'attribute_groups' => $attribute_groups, 'attribute_js' => $js_attributes, 'toolbar_btn' => $this->toolbar_btn, 'toolbar_scroll' => true, 'title' => $this->toolbar_title)); }
public function displayForm() { global $currentIndex, $cookie; $jsAttributes = self::displayAndReturnAttributeJs(); $attributesGroups = AttributeGroup::getAttributesGroups(intval($cookie->id_lang)); $this->product = new Product(intval(Tools::getValue('id_product'))); if (isset($_POST['generate']) and !sizeof($this->_errors)) { echo ' <div class="module_confirmation conf confirm"> <img src="../img/admin/ok.gif" alt="" title="" style="margin-right:5px; float:left;" /> ' . sizeof($this->combinations) . ' ' . $this->l('product(s) successfully created.') . ' </div>'; } echo ' <script type="text/javascript" src="../js/attributesBack.js"></script> <form enctype="multipart/form-data" method="post" id="generator" action=""' . $currentIndex . '&id_category=' . intval(Tools::getValue('id_category')) . 'token=' . Tools::getValue('token') . '"> <fieldset style="margin-bottom: 35px;"><legend><img src="../img/admin/asterisk.gif" />' . $this->l('Attributes generator') . '</legend>' . $this->l('Add or modify attributes for this product:') . ' <br /><br /> '; echo ' <div style="padding-top:10px; float: left; width: 570px;"> <div style="float:left;"> <label>' . $this->l('Quantity:') . '</label> <div class="margin-form"> <input type="text" size="20" name="quantity" value="1"/> </div> <label>' . $this->l('Reference:') . '</label> <div class="margin-form"> <input type="text" size="20" name="reference" value="' . $this->product->reference . '"/> </div> </div> <div style="float:left; text-align:center; margin-left:20px;"> <input type="submit" class="button" style="margin-bottom:5px;" name="generate" value="' . $this->l('Generate') . '" /><br /> <input type="submit" class="button" name="back" value="' . $this->l('Back to product') . '" /> </div> <br style="clear:both;" /> <div style="margin-top: 15px;">'; self::displayGroupeTable($jsAttributes, $attributesGroups); echo ' </div> </div> <div style="float: left; margin-left: 60px;"> '; self::displayGroupSelect($jsAttributes, $attributesGroups); echo ' <div> <input class="button" type="button" style="margin-left: 20px;" value="' . $this->l('Add') . '" class="button" onclick="add_attr_multiple();" /> <input class="button" type="button" style="margin-left: 20px;" value="' . $this->l('Delete') . '" class="button" onclick="del_attr_multiple();" /> </div> </div> <br /> </fieldset> </form>'; }
public function getAllAttributes() { $all_Attribut = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('SELECT `id_attribute_eco`, `value` FROM `' . _DB_PREFIX_ . 'ec_ecopresto_attribute`'); $response = ''; $Attribut_PS = AttributeGroup::getAttributesGroups(self::getInfoEco('ID_LANG')); foreach ($all_Attribut as $attribut) { $attribut_eco = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT id_attribute FROM `' . _DB_PREFIX_ . 'ec_ecopresto_attribute_shop` WHERE `id_attribute_eco`=' . (int) $attribut['id_attribute_eco'] . ' AND `id_shop`=' . (int) self::getInfoEco('ID_SHOP')); $response .= '<p>Attribut EcoPresto :' . $attribut['value'] . ' =>'; $response .= ' <select name="attribut_ps[]"> <option value="' . $attribut['id_attribute_eco'] . '_0"> Créer automatiquement </option>'; foreach ($Attribut_PS as $attributPS) { $response .= '<option value="' . $attribut['id_attribute_eco'] . '_' . $attributPS['id_attribute_group'] . '" ' . ($attribut_eco == $attributPS['id_attribute_group'] ? 'selected="selected"' : '') . '>' . $attributPS['name'] . '</option>'; } $response .= '</select>'; } return $response; }
/** * Display the BO html with smart templates */ public function _displayForm() { // Add the specific jquery ui plugins, module JS & CSS $this->context->controller->addJqueryUI('ui.tabs'); $this->context->controller->addJqueryPlugin('autocomplete'); $this->context->controller->addJs($this->_path . 'js/admin/' . $this->name . '.js'); $this->context->controller->addCss(array($this->_path . 'css/admin/' . $this->name . '.css' => 'all', _PS_JS_DIR_ . 'jquery/ui/themes/base/jquery.ui.all.css')); /* Display the errors / warnings / confirmations */ $this->context->smarty->assign(array('aPrediggoWarnings' => $this->_warnings, 'aPrediggoConfirmations' => $this->_confirmations, 'aPrediggoErrors' => $this->_errors, 'path' => $this->_path, 'lang_iso' => $this->context->language->iso_code)); // Display the errors $this->_html .= $this->display(__FILE__, 'views/templates/admin/errors.tpl'); // Display the tabs $this->_html .= $this->display(__FILE__, 'views/templates/admin/tabs.tpl'); $this->_display = 'index'; $iShopContext = (int) (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP); /* * MAIN CONFIGURATION */ $this->fields_form['main_conf']['form'] = array('legend' => array('title' => $this->l('Main Configuration'), 'image' => _PS_ADMIN_IMG_ . 'employee.gif'), 'input' => array(array('label' => $this->l('Web Site ID'), 'type' => 'text', 'name' => 'web_site_id', 'size' => 50, 'required' => true, 'desc' => $this->l('Login of the Prediggo solution')), array('label' => $this->l('Profil ID'), 'type' => 'text', 'name' => 'gateway_profil_id', 'size' => 50, 'disabled' => 'disabled', 'desc' => $this->l('Profile ID of the current shop')), array('type' => 'button', 'name' => 'mainConfSubmit', 'class' => 'button', 'title' => $this->l(' Save ')))); $this->fields_value['web_site_id'] = $this->oPrediggoConfig->web_site_id; $this->fields_value['gateway_profil_id'] = (int) $this->context->shop->id; /* * EXPORT MAIN CONFIGURATION */ $sCronFilePath = Tools::getShopDomain(true) . str_replace(_PS_ROOT_DIR_ . '/', __PS_BASE_URI__, $this->_path) . 'crons/export.php?token=' . Tools::getAdminToken('DataExtractorController'); $this->fields_form['export_conf']['form'] = array('legend' => array('title' => $this->l('Export Configuration'), 'image' => _PS_ADMIN_IMG_ . 'cog.gif'), 'input' => array(array('label' => $this->l('Logs storage activation'), 'type' => 'radio', 'name' => 'logs_file_generation', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'logs_file_generation_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'logs_file_generation_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('The logs files are stored in the folder "logs" of the module')), array('label' => $this->l('Products file generation activation'), 'type' => 'radio', 'name' => 'products_file_generation', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'products_file_generation_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'products_file_generation_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Define if the products can be exported into a zip file for the use of the prediggo solution'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Orders file generation activation'), 'type' => 'radio', 'name' => 'orders_file_generation', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'orders_file_generation_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'orders_file_generation_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Define if the orders can be exported into a zip file for the use of the prediggo solution'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Customers file generation activation'), 'type' => 'radio', 'name' => 'customers_file_generation', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'customers_file_generation_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'customers_file_generation_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Define if the customers can be exported into a zip file for the use of the prediggo solution'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Product\'s image cover export activation'), 'type' => 'radio', 'name' => 'export_product_image', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'export_product_image_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'export_product_image_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Define if the product\'s image covers are included in the export of the products'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Product\'s description export activation'), 'type' => 'radio', 'name' => 'export_product_description', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'export_product_description_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'export_product_description_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Define if the product\'s descriptions are included in the export of the products'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Product minimum quantity:'), 'type' => 'text', 'name' => 'export_product_min_quantity', 'required' => true, 'desc' => $this->l('Minimum quantity of a product to be exported'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Number of days considering that an order can be exported:'), 'type' => 'text', 'name' => 'nb_days_order_valide', 'required' => true, 'desc' => $this->l('Number of days to select orders into the export by their date of creation'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Number of days considering that a customer can be exported:'), 'type' => 'text', 'name' => 'nb_days_customer_last_visit_valide', 'required' => true, 'desc' => $this->l('Number of days to select customers into the export by their date of creation'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'exportConfSubmit', 'class' => 'button', 'title' => $this->l(' Save '), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'hint', 'name' => 'protection_xml_path', 'content' => $this->l('If you want to execute the export by a cron, use the following link:') . ' <a href="' . $sCronFilePath . '">' . $sCronFilePath . '</a>.'), array('label' => $this->l('Launch the files export by clicking on the following button:'), 'type' => 'button', 'name' => 'manualExportSubmit', 'class' => 'button', 'title' => $this->l(' Export files '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['products_file_generation'] = (int) $this->oPrediggoConfig->products_file_generation; $this->fields_value['orders_file_generation'] = (int) $this->oPrediggoConfig->orders_file_generation; $this->fields_value['customers_file_generation'] = (int) $this->oPrediggoConfig->customers_file_generation; $this->fields_value['logs_file_generation'] = (int) $this->oPrediggoConfig->logs_file_generation; $this->fields_value['export_product_image'] = (int) $this->oPrediggoConfig->export_product_image; $this->fields_value['export_product_description'] = (int) $this->oPrediggoConfig->export_product_description; $this->fields_value['export_product_min_quantity'] = (int) $this->oPrediggoConfig->export_product_min_quantity; $this->fields_value['nb_days_order_valide'] = (int) $this->oPrediggoConfig->nb_days_order_valide; $this->fields_value['nb_days_customer_last_visit_valide'] = (int) $this->oPrediggoConfig->nb_days_customer_last_visit_valide; /* * ATTRIBUTE SELECTION */ $this->fields_form['attributes_selection']['form'] = array('legend' => array('title' => $this->l('Prediggo attributes selection'), 'image' => _PS_ADMIN_IMG_ . 'quick.gif'), 'input' => array(array('label' => $this->l('Attributes:'), 'type' => 'attribute_selector', 'name' => 'attribute_selector', 'names' => array('attributes' => 'attributes_groups_ids[]', 'features' => 'features_ids[]'), 'values' => array('attributes' => AttributeGroup::getAttributesGroups((int) $this->context->cookie->id_lang), 'features' => Feature::getFeatures((int) $this->context->cookie->id_lang)), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'exportPrediggoAttributesSubmit', 'class' => 'button', 'title' => $this->l(' Save the prediggo attributes '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['attribute_selector'] = array('attributes' => explode(',', $this->oPrediggoConfig->attributes_groups_ids), 'features' => explode(',', $this->oPrediggoConfig->features_ids)); /* * RECOMMANDATIONS BLACK LIST */ $this->fields_form['black_list_reco']['form'] = array('legend' => array('title' => $this->l('Products not included in the recommendations'), 'image' => _PS_ADMIN_IMG_ . 'nav-logout.gif'), 'input' => array(array('label' => $this->l('Product:'), 'type' => 'autocomplete', 'name' => 'products_ids_not_recommendable', 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'exportNotRecoSubmit', 'class' => 'button', 'title' => $this->l(' Save the black list '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['products_ids_not_recommendable'] = array(); if (!empty($this->oPrediggoConfig->products_ids_not_recommendable)) { foreach (explode(',', $this->oPrediggoConfig->products_ids_not_recommendable) as $iID) { $oProduct = new Product((int) $iID, false, (int) $this->context->cookie->id_lang, (int) $this->context->shop->id, $this->context); $this->fields_value['products_ids_not_recommendable'][] = array('id' => (int) $iID, 'name' => $oProduct->name); unset($oProduct); } } /* * SEARCH BLACK LIST */ $this->fields_form['black_list_search']['form'] = array('legend' => array('title' => $this->l('Products not included in the searchs'), 'image' => _PS_ADMIN_IMG_ . 'nav-logout.gif'), 'input' => array(array('label' => $this->l('Product:'), 'type' => 'autocomplete', 'name' => 'products_ids_not_searchable', 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'exportNotSearchSubmit', 'class' => 'button', 'title' => $this->l(' Save the black list '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['products_ids_not_searchable'] = array(); if (!empty($this->oPrediggoConfig->products_ids_not_searchable)) { foreach (explode(',', $this->oPrediggoConfig->products_ids_not_searchable) as $iID) { $oProduct = new Product((int) $iID, false, (int) $this->context->cookie->id_lang, (int) $this->context->shop->id, $this->context); $this->fields_value['products_ids_not_searchable'][] = array('id' => (int) $iID, 'name' => $oProduct->name); unset($oProduct); } } /* * HTACCESS PROTECTION */ $sExportRepositoryPath = Tools::getShopDomain(true) . str_replace(_PS_ROOT_DIR_ . '/', __PS_BASE_URI__, $this->_path) . 'xmlfiles/'; $this->fields_form['htaccess_conf']['form'] = array('legend' => array('title' => $this->l('Export File protection'), 'image' => _PS_ADMIN_IMG_ . 'access.png'), 'input' => array(array('type' => 'hint', 'name' => 'export_cron', 'content' => $this->l('Your files are created into your PrestaShop plateform into the following folder :') . ' <a href="' . $sExportRepositoryPath . '">' . $sExportRepositoryPath . '</a>.<br/>' . $this->l('The data contained into these files are critical and require a protection.') . $this->l('Please restrict the access to these files by applying a protection with an authentication requiring a login and a password!') . '<br/>' . $this->l('The Basic Authentication module is not configured by default on Nginx web server. Please, refer to this documentation to configure it : http://wiki.nginx.org/HttpAuthBasicModule.')), array('label' => $this->l('Login:'******'type' => 'text', 'name' => 'htpasswd_user', 'required' => true, 'desc' => $this->l('Login of the export folder protection')), array('label' => $this->l('Password:'******'type' => 'text', 'name' => 'htpasswd_pwd', 'required' => true, 'desc' => $this->l('Password of the export folder protection')), array('type' => 'button', 'name' => 'exportProtectionConfSubmit', 'class' => 'button', 'title' => $this->l(' Save ')))); $this->fields_value['htpasswd_user'] = $this->oPrediggoConfig->htpasswd_user; $this->fields_value['htpasswd_pwd'] = $this->oPrediggoConfig->htpasswd_pwd; /* * RECOMMENDATIONS MAIN CONFIGURATION */ $this->fields_form['recommendation_conf']['form'] = array('legend' => array('title' => $this->l('Main recommendations settings'), 'image' => _PS_ADMIN_IMG_ . 'page_world.png'), 'input' => array(array('label' => $this->l('Logs storage activation:'), 'type' => 'radio', 'name' => 'logs_reco_file_generation', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'logs_reco_file_generation_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'logs_reco_file_generation_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('The logs files are stored in the folder "logs" of the module'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('URL of the recommendations server:'), 'type' => 'text', 'name' => 'server_url_recommendations', 'size' => 50, 'required' => true, 'desc' => $this->l('Url called to get the recommendations from the prediggo solution'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'mainRecommendationConfSubmit', 'class' => 'button', 'title' => $this->l(' Save '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['logs_reco_file_generation'] = (int) $this->oPrediggoConfig->logs_reco_file_generation; $this->fields_value['server_url_recommendations'] = $this->oPrediggoConfig->server_url_recommendations; /* * HOMEPAGE RECOMMENDATIONS */ $this->fields_form['home_reco_conf']['form'] = array('legend' => array('title' => $this->l('Home page configuration'), 'image' => _PS_ADMIN_IMG_ . 'picture.gif'), 'input' => array(array('label' => $this->l('Display the recommendations block:'), 'type' => 'radio', 'name' => 'home_recommendations', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'home_recommendations_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'home_recommendations_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Add a block of recommended products in the homepage of your website'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Number of items in the recommendations block:'), 'type' => 'text', 'name' => 'home_nb_items', 'desc' => $this->l('Number of recommended products in the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Title of the recommendation block :'), 'type' => 'text', 'size' => 50, 'name' => 'home_block_title', 'lang' => true, 'desc' => $this->l('Title of the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'exportHomeRecommendationConfSubmit', 'class' => 'button', 'title' => $this->l(' Save '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['home_recommendations'] = (int) $this->oPrediggoConfig->home_recommendations; $this->fields_value['home_nb_items'] = (int) $this->oPrediggoConfig->home_nb_items; $this->fields_value['home_block_title'] = $this->oPrediggoConfig->home_block_title; /* * 404 PAGE RECOMMENDATIONS */ $this->fields_form['error_reco_conf']['form'] = array('legend' => array('title' => $this->l('404 page configuration'), 'image' => _PS_ADMIN_IMG_ . 'picture.gif'), 'input' => array(array('label' => $this->l('Display the recommendations block:'), 'type' => 'radio', 'name' => 'error_recommendations', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'error_recommendations_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'error_recommendations_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Add a block of recommended products in the 404 page of your website'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Number of items in the recommendations block:'), 'type' => 'text', 'name' => 'error_nb_items', 'desc' => $this->l('Number of recommended products in the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Title of the recommendation block :'), 'type' => 'text', 'name' => 'error_block_title', 'size' => 50, 'lang' => true, 'desc' => $this->l('Title of the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'export404RecommendationConfSubmit', 'class' => 'button', 'title' => $this->l(' Save '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['error_recommendations'] = (int) $this->oPrediggoConfig->error_recommendations; $this->fields_value['error_nb_items'] = (int) $this->oPrediggoConfig->error_nb_items; $this->fields_value['error_block_title'] = $this->oPrediggoConfig->error_block_title; /* * PRODUCT PAGE RECOMMENDATIONS */ $this->fields_form['product_reco_conf']['form'] = array('legend' => array('title' => $this->l('Product page configuration'), 'image' => _PS_ADMIN_IMG_ . 'picture.gif'), 'input' => array(array('label' => $this->l('Display the recommendations block:'), 'type' => 'radio', 'name' => 'product_recommendations', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'product_recommendations_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'product_recommendations_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Add a block of recommended products in the products pages of your website'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Number of items in the recommendations block:'), 'type' => 'text', 'name' => 'product_nb_items', 'desc' => $this->l('Number of recommended products in the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Title of the recommendation block :'), 'type' => 'text', 'name' => 'product_block_title', 'size' => 50, 'lang' => true, 'desc' => $this->l('Title of the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'exportProductRecommendationConfSubmit', 'class' => 'button', 'title' => $this->l(' Save '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['product_recommendations'] = (int) $this->oPrediggoConfig->product_recommendations; $this->fields_value['product_nb_items'] = (int) $this->oPrediggoConfig->product_nb_items; $this->fields_value['product_block_title'] = $this->oPrediggoConfig->product_block_title; /* * CATEGORY PAGE RECOMMENDATIONS */ $this->fields_form['category_reco_conf']['form'] = array('legend' => array('title' => $this->l('Category page configuration'), 'image' => _PS_ADMIN_IMG_ . 'picture.gif'), 'input' => array(array('label' => $this->l('Display the recommendations block:'), 'type' => 'radio', 'name' => 'category_recommendations', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'category_recommendations_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'category_recommendations_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Add a block of recommended products in the categories pages of your website'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Number of items in the recommendations block:'), 'type' => 'text', 'name' => 'category_nb_items', 'desc' => $this->l('Number of recommended products in the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Title of the recommendation block :'), 'type' => 'text', 'name' => 'category_block_title', 'size' => 50, 'lang' => true, 'desc' => $this->l('Title of the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'exportCategoryRecommendationConfSubmit', 'class' => 'button', 'title' => $this->l(' Save '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['category_recommendations'] = (int) $this->oPrediggoConfig->category_recommendations; $this->fields_value['category_nb_items'] = (int) $this->oPrediggoConfig->category_nb_items; $this->fields_value['category_block_title'] = $this->oPrediggoConfig->category_block_title; /* * CUSTOMER PAGE RECOMMENDATIONS */ $this->fields_form['customer_reco_conf']['form'] = array('legend' => array('title' => $this->l('Customers pages configuration'), 'image' => _PS_ADMIN_IMG_ . 'picture.gif'), 'input' => array(array('label' => $this->l('Display the recommendations block:'), 'type' => 'radio', 'name' => 'customer_recommendations', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'customer_recommendations_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'customer_recommendations_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Add a block of recommended products in the customers pages of your website'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Number of items in the recommendations block:'), 'type' => 'text', 'name' => 'customer_nb_items', 'desc' => $this->l('Number of recommended products in the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Title of the recommendation block :'), 'type' => 'text', 'name' => 'customer_block_title', 'size' => 50, 'lang' => true, 'desc' => $this->l('Title of the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'exportCustomerRecommendationConfSubmit', 'class' => 'button', 'title' => $this->l(' Save '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['customer_recommendations'] = (int) $this->oPrediggoConfig->customer_recommendations; $this->fields_value['customer_nb_items'] = (int) $this->oPrediggoConfig->customer_nb_items; $this->fields_value['customer_block_title'] = $this->oPrediggoConfig->customer_block_title; /* * CART PAGE RECOMMENDATIONS */ $this->fields_form['cart_reco_conf']['form'] = array('legend' => array('title' => $this->l('Cart page configuration'), 'image' => _PS_ADMIN_IMG_ . 'picture.gif'), 'input' => array(array('label' => $this->l('Display the recommendations block:'), 'type' => 'radio', 'name' => 'cart_recommendations', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'cart_recommendations_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'cart_recommendations_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Add a block of recommended products in the cart page of your website'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Number of items in the recommendations block:'), 'type' => 'text', 'name' => 'cart_nb_items', 'desc' => $this->l('Number of recommended products in the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Title of the recommendation block :'), 'type' => 'text', 'name' => 'cart_block_title', 'size' => 50, 'lang' => true, 'desc' => $this->l('Title of the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'exportCartRecommendationConfSubmit', 'class' => 'button', 'title' => $this->l(' Save '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['cart_recommendations'] = (int) $this->oPrediggoConfig->cart_recommendations; $this->fields_value['cart_nb_items'] = (int) $this->oPrediggoConfig->cart_nb_items; $this->fields_value['cart_block_title'] = $this->oPrediggoConfig->cart_block_title; /* * BLOCK LAYERED MODULE RECOMMENDATIONS */ $this->fields_form['blocklayered_reco_conf']['form'] = array('legend' => array('title' => $this->l('Block layered module configuration'), 'image' => _PS_ADMIN_IMG_ . 'picture.gif'), 'input' => array(array('label' => $this->l('Display the recommendations block:'), 'type' => 'radio', 'name' => 'blocklayered_recommendations', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'blocklayered_recommendations_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'blocklayered_recommendations_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Add a block of recommended products in the block layered module'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Number of items in the recommendations block:'), 'type' => 'text', 'name' => 'blocklayered_nb_items', 'desc' => $this->l('Number of recommended products in the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Title of the recommendation block :'), 'type' => 'text', 'name' => 'blocklayered_block_title', 'size' => 50, 'lang' => true, 'desc' => $this->l('Title of the block'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'exportBlocklayeredRecommendationConfSubmit', 'class' => 'button', 'title' => $this->l(' Save '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['blocklayered_recommendations'] = (int) $this->oPrediggoConfig->blocklayered_recommendations; $this->fields_value['blocklayered_nb_items'] = (int) $this->oPrediggoConfig->blocklayered_nb_items; $this->fields_value['blocklayered_block_title'] = $this->oPrediggoConfig->blocklayered_block_title; /* * SEARCH MAIN CONFIGURATION */ $this->fields_form['search_conf']['form'] = array('legend' => array('title' => $this->l('Main search settings'), 'image' => _PS_ADMIN_IMG_ . 'search.gif'), 'input' => array(array('label' => $this->l('Display the search block:'), 'type' => 'radio', 'name' => 'search_active', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'search_active_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'search_active_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Enable the search block in the front office'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Number of items per page:'), 'type' => 'text', 'name' => 'search_nb_items', 'desc' => $this->l('Number of products per page'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Minimum number of chars to launch a search:'), 'type' => 'text', 'name' => 'search_nb_min_chars', 'desc' => $this->l('Minimum number of character to allow the user to execute a search'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Logs storage activation:'), 'type' => 'radio', 'name' => 'logs_search_file_generation', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'logs_search_file_generation_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'logs_search_file_generation_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('The logs files are stored in the folder "logs" of the module'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('URL of the search server:'), 'type' => 'text', 'name' => 'server_url_search', 'desc' => $this->l('Url called to get the search from the prediggo solution'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Searchandizing activation:'), 'type' => 'radio', 'name' => 'searchandizing_active', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'searchandizing_active_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'searchandizing_active_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Enable the searchandizing block in the front office'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Layered navigation activation:'), 'type' => 'radio', 'name' => 'layered_navigation_active', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'layered_navigation_active_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'layered_navigation_active_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Enable the prediggo layered navigation in the search page of the front office'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'mainSearchConfSubmit', 'class' => 'button', 'title' => $this->l(' Save '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['search_active'] = (int) $this->oPrediggoConfig->search_active; $this->fields_value['search_nb_items'] = (int) $this->oPrediggoConfig->search_nb_items; $this->fields_value['search_nb_min_chars'] = (int) $this->oPrediggoConfig->search_nb_min_chars; $this->fields_value['logs_search_file_generation'] = (int) $this->oPrediggoConfig->logs_search_file_generation; $this->fields_value['server_url_search'] = $this->oPrediggoConfig->server_url_search; $this->fields_value['searchandizing_active'] = (int) $this->oPrediggoConfig->searchandizing_active; $this->fields_value['layered_navigation_active'] = (int) $this->oPrediggoConfig->layered_navigation_active; /* * SEARCH AUTOCOMPLETION CONFIGURATION */ $this->fields_form['search_autocompletion_conf']['form'] = array('legend' => array('title' => $this->l('Autocompletion configuration'), 'image' => _PS_ADMIN_IMG_ . 'download_page.png'), 'input' => array(array('label' => $this->l('Autocompletion activation:'), 'type' => 'radio', 'name' => 'autocompletion_active', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'autocompletion_active_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'autocompletion_active_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Enable the prediggo autocompletion to propose words when the customer is typing his search'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Number of items in the search autocompletion:'), 'type' => 'text', 'name' => 'autocompletion_nb_items', 'desc' => $this->l('Number of products displayed in the prediggo autocompletion'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('Suggestion activation:'), 'type' => 'radio', 'name' => 'suggest_active', 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'suggest_active_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'suggest_active_off', 'value' => 0, 'label' => $this->l('No'))), 'required' => true, 'desc' => $this->l('Enable the prediggo suggestion to propose words when the customer is typing his search'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('label' => $this->l('List of suggestion:'), 'type' => 'text', 'name' => 'suggest_words', 'lang' => true, 'desc' => $this->l('List of keywords separated by comma (iPad 2, iPhone 4S, iPhone)'), 'disabled' => (int) $iShopContext ? 'disabled' : ''), array('type' => 'button', 'name' => 'exportSearchAutocompletionConfSubmit', 'class' => 'button', 'title' => $this->l(' Save '), 'disabled' => (int) $iShopContext ? 'disabled' : ''))); $this->fields_value['autocompletion_active'] = (int) $this->oPrediggoConfig->autocompletion_active; $this->fields_value['autocompletion_nb_items'] = (int) $this->oPrediggoConfig->autocompletion_nb_items; $this->fields_value['suggest_active'] = (int) $this->oPrediggoConfig->suggest_active; $this->fields_value['suggest_words'] = $this->oPrediggoConfig->suggest_words; $this->context->controller->getLanguages(); $helper = $this->initForm(); $helper->submit_action = ''; $helper->title = $this->l('Prediggo configuration'); if (Shop::getContext() == Shop::CONTEXT_SHOP) { $helper->title .= ' [ ' . $this->l('Shop') . ' : ' . $this->context->shop->name . ' ]'; } else { $helper->title .= ' [ ' . $this->l('All shops') . ' ]'; } $helper->fields_value = $this->fields_value; $this->_html .= $helper->generateForm($this->fields_form); }
protected function getReadableFields($fields) { global $cookie; $titles = array('id_product' => array('name' => $this->l('Product ID', __CLASS__), 'class' => 'prodRel'), 'active' => array('name' => $this->l('Product status', __CLASS__), 'class' => 'prodRel'), 'date_add' => array('name' => $this->l('Addition date', __CLASS__), 'class' => 'prodRel'), 'date_upd' => array('name' => $this->l('Update date', __CLASS__), 'class' => 'prodRel'), 'id_category_default' => array('name' => $this->l('Default Category ID', __CLASS__), 'class' => 'prodRel'), 'id_manufacturer' => array('name' => $this->l('Manufacturer ID', __CLASS__), 'class' => 'prodRel'), 'id_supplier' => array('name' => $this->l('Supplier ID', __CLASS__), 'class' => 'prodRel'), 'id_tax' => array('name' => $this->l('Tax ID', __CLASS__), 'class' => 'prodRel'), 'description' => array('name' => $this->l('Description', __CLASS__), 'class' => 'prodRel'), 'description_short' => array('name' => $this->l('Short Description', __CLASS__), 'class' => 'prodRel'), 'meta_description' => array('name' => $this->l('Meta Description', __CLASS__), 'class' => 'prodRel'), 'meta_keywords' => array('name' => $this->l('Meta Keywords', __CLASS__), 'class' => 'prodRel'), 'meta_title' => array('name' => $this->l('Meta Title', __CLASS__), 'class' => 'prodRel'), 'quantity' => array('name' => $this->l('Quantity in stock', __CLASS__), 'class' => 'prodRel'), 'name' => array('name' => $this->l('Product\'s name', __CLASS__), 'class' => 'prodRel'), 'reference' => array('name' => $this->l('Reference', __CLASS__), 'class' => 'prodRel'), 'supplier_reference' => array('name' => $this->l('Supplier\'s Reference', __CLASS__), 'class' => 'prodRel'), 'weight' => array('name' => $this->l('Weight', __CLASS__), 'class' => 'prodRel'), 'wholesale_price' => array('name' => $this->l('Wholesale Price', __CLASS__), 'class' => 'prodRel'), 'price' => array('name' => $this->l('Price', __CLASS__), 'class' => 'prodRel'), 'ecotax' => array('name' => $this->l('Ecotax', __CLASS__), 'class' => 'prodRel'), 'location' => array('name' => $this->l('Location', __CLASS__), 'class' => 'prodRel'), 'ean13' => array('name' => $this->l('Ean13', __CLASS__), 'class' => 'prodRel'), 'reduction_from' => array('name' => $this->l('Reduction from', __CLASS__), 'class' => 'prodRel'), 'reduction_to' => array('name' => $this->l('Reduction to', __CLASS__), 'class' => 'prodRel'), 'reduction_percent' => array('name' => $this->l('Reduction percent', __CLASS__), 'class' => 'prodRel'), 'reduction_price' => array('name' => $this->l('Reduction price', __CLASS__), 'class' => 'prodRel'), 'available_now' => array('name' => $this->l('Available now', __CLASS__), 'class' => 'prodRel'), 'available_later' => array('name' => $this->l('Available later', __CLASS__), 'class' => 'prodRel'), 'available_for_order' => array('name' => $this->l('Available for order', __CLASS__), 'class' => 'prodRel'), 'additional_shipping_cost' => array('name' => $this->l('Additional shipping cost', __CLASS__), 'class' => 'prodRel'), 'condition' => array('name' => $this->l('Condition', __CLASS__), 'class' => 'prodRel'), 'height' => array('name' => $this->l('Height', __CLASS__), 'class' => 'prodRel'), 'width' => array('name' => $this->l('Width', __CLASS__), 'class' => 'prodRel'), 'depth' => array('name' => $this->l('Depth', __CLASS__), 'class' => 'prodRel'), 'upc' => array('name' => $this->l('UPC', __CLASS__), 'class' => 'prodRel'), 'show_price' => array('name' => $this->l('Show price', __CLASS__), 'class' => 'prodRel'), 'unit_price_ratio' => array('name' => $this->l('Unit Price ratio', __CLASS__), 'class' => 'prodRel'), 'online_only' => array('name' => $this->l('Online Only', __CLASS__), 'class' => 'prodRel'), 'minimal_quantity' => array('name' => $this->l('Minimal quantity', __CLASS__), 'class' => 'prodRel'), 'id_tax_rules_group' => array('name' => $this->l('Tax Rule Group ID', __CLASS__), 'class' => 'prodRel'), 'unity' => array('name' => $this->l('Unity', __CLASS__), 'class' => 'prodRel')); $result = array(); foreach ($fields as $field) { $result[$field] = isset($titles[$field]) ? $titles[$field] : array('name' => $field, 'class' => 'prodRel'); } $result['tax_rate'] = array('name' => $this->l('Tax Rate', __CLASS__), 'class' => 'prodRel'); $result['total_tax'] = array('name' => $this->l('Total Tax', __CLASS__), 'class' => 'prodRel'); $result['manufacturer_name'] = array('name' => $this->l('Manufacturer', __CLASS__), 'class' => 'prodRel'); $result['supplier_name'] = array('name' => $this->l('Supplier', __CLASS__), 'class' => 'prodRel'); $result['picture_link'] = array('name' => $this->l('Picture url', __CLASS__), 'class' => 'prodRel'); $result['product_link'] = array('name' => $this->l('Product url', __CLASS__), 'class' => 'prodRel'); $result['shipping_price'] = array('name' => $this->l('Shipping Price', __CLASS__), 'class' => 'prodRel'); $result['shipping_with_fee'] = array('name' => $this->l('Shipping price including COD fee', __CLASS__), 'class' => 'prodRel'); $result['category_name'] = array('name' => $this->l('Category Name', __CLASS__), 'class' => 'prodRel'); $result['price_with_tax'] = array('name' => $this->l('Price (tax incl)', __CLASS__), 'class' => 'prodRel'); uasort($result, array($this, 'cmpField')); //get group of attributes $attr_result = array(); $attrGroups = AttributeGroup::getAttributesGroups($cookie->id_lang); foreach ($attrGroups as $ag) { $attr_result['ag' . $ag['id_attribute_group']] = array('name' => $ag['name'], 'class' => 'attrRel'); } uasort($attr_result, array($this, 'cmpField')); $result = $result + $attr_result; //get features $feat_result = array(); $features = Feature::getFeatures($cookie->id_lang); foreach ($features as $ft) { $feat_result['ft' . $ft['id_feature']] = array('name' => $ft['name'], 'class' => 'featRel'); } uasort($feat_result, array($this, 'cmpField')); $result = $result + $feat_result; $result['empty_field'] = array('name' => $this->l('Empty Field', __CLASS__), 'class' => 'specialRel'); return $result; }
/** * Display form * * @global string $currentIndex Current URL in order to keep current Tab */ public function displayForm($token = NULL) { global $currentIndex; $defaultLanguage = intval(Configuration::get('PS_LANG_DEFAULT')); $languages = Language::getLanguages(); $obj = $this->loadObject(true); $color = $obj->color ? $obj->color : 0; $attributes_groups = AttributeGroup::getAttributesGroups($defaultLanguage); echo ' <script type="text/javascript"> id_language = Number(' . $defaultLanguage . '); var attributesGroups = new Array(); '; foreach ($attributes_groups as $attribute_group) { echo 'attributesGroups[' . $attribute_group['id_attribute_group'] . '] = ' . $attribute_group['is_color_group'] . ';' . "\n"; } echo ' </script> <form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . ($token ? $token : $this->token) . '" method="post" enctype="multipart/form-data"> ' . ($obj->id ? '<input type="hidden" name="id_attribute" value="' . $obj->id . '" />' : '') . ' <fieldset class="width3"><legend><img src="../img/admin/asterisk.gif" />' . $this->l('Attribute') . '</legend> <label>' . $this->l('Name:') . ' </label> <div class="margin-form">'; foreach ($languages as $language) { echo ' <div id="name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $defaultLanguage ? 'block' : 'none') . '; float: left;"> <input size="33" type="text" name="name_' . $language['id_lang'] . '" value="' . htmlspecialchars($this->getFieldValue($obj, 'name', intval($language['id_lang']))) . '" /><sup> *</sup> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } $this->displayFlags($languages, $defaultLanguage, 'name', 'name'); echo ' <div style="clear: both;"></div> </div> <label>' . $this->l('Group:') . ' </label> <div class="margin-form"> <select name="id_attribute_group" id="id_attribute_group" onchange="showAttributeColorGroup(\'id_attribute_group\', \'colorAttributeProperties\')">'; foreach ($attributes_groups as $attribute_group) { echo '<option value="' . $attribute_group['id_attribute_group'] . '"' . ($this->getFieldValue($obj, 'id_attribute_group') == $attribute_group['id_attribute_group'] ? ' selected="selected"' : '') . '>' . $attribute_group['name'] . '</option>'; } echo ' </select><sup> *</sup> </div> <div id="colorAttributeProperties" style="' . ((Validate::isLoadedObject($obj) and $obj->isColorAttribute()) ? 'display: block;' : 'display: none;') . '"> <label>' . $this->l('Color:') . '</label> <div class="margin-form"> <input type="text" size="33" name="color" value="' . (Tools::getValue('color', $color) ? htmlentities(Tools::getValue('color', $color)) : '#000000') . '" /> <sup>*</sup> <p class="clear">' . $this->l('HTML colors only (e.g.,') . ' "lightblue", "#CC6600")</p> </div> <label>' . $this->l('Texture:') . ' </label> <div class="margin-form"> <input type="file" name="texture" /> <p>' . $this->l('Upload color texture from your computer') . '<br />' . $this->l('This will override the HTML color!') . '</p> </div> <label>' . $this->l('Current texture:') . ' </label> <div class="margin-form"> <p>' . (file_exists(_PS_IMG_DIR_ . $this->fieldImageSettings['dir'] . '/' . $obj->id . '.jpg') ? '<img src="../img/' . $this->fieldImageSettings['dir'] . '/' . $obj->id . '.jpg" alt="" title="" /> <a href="' . $_SERVER['REQUEST_URI'] . '&deleteImage=1"><img src="../img/admin/delete.gif" alt="' . $this->l('delete') . '" title="" /></a>' : $this->l('None')) . '</p> </div> </div> <div class="margin-form"> <input type="submit" value="' . $this->l(' Save ') . '" name="submitAddattribute" class="button" /> </div> <div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div> </fieldset> </form>'; }
public function getAttributes() { $attributes = AttributeGroup::getAttributesGroups($this->context->language->id); $selectAttributes = array(); $selectAttributes[0]['id_option'] = 0; $selectAttributes[0]['name'] = $this->l('Select size attribute'); foreach ($attributes as $attribute) { $selectAttributes[$attribute['id_attribute_group']]['id_option'] = $attribute['id_attribute_group']; $selectAttributes[$attribute['id_attribute_group']]['name'] = $attribute['name']; } return $selectAttributes; }
/** * Display form * * @global string $currentIndex Current URL in order to keep current Tab */ public function displayForm($token = NULL) { global $currentIndex; parent::displayForm(); if (!($obj = $this->loadObject(true))) { return; } $color = $obj->color ? $obj->color : 0; $attributes_groups = AttributeGroup::getAttributesGroups($this->_defaultFormLanguage); $strAttributesGroups = ''; echo ' <script type="text/javascript"> var attributesGroups = {'; foreach ($attributes_groups as $attribute_group) { $strAttributesGroups .= '"' . $attribute_group['id_attribute_group'] . '" : ' . $attribute_group['is_color_group'] . ','; } echo $strAttributesGroups . '}; </script> <form action="' . $currentIndex . '&submitAdd' . $this->table . '=1&token=' . ($token ? $token : $this->token) . '" method="post" enctype="multipart/form-data"> ' . ($obj->id ? '<input type="hidden" name="id_attribute" value="' . $obj->id . '" />' : '') . ' <fieldset><legend><img src="../img/admin/asterisk.gif" />' . $this->l('Attribute') . '</legend> <label>' . $this->l('Name:') . ' </label> <div class="margin-form">'; foreach ($this->_languages as $language) { echo ' <div id="name_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;"> <input size="33" type="text" name="name_' . $language['id_lang'] . '" value="' . htmlspecialchars($this->getFieldValue($obj, 'name', (int) $language['id_lang'])) . '" /><sup> *</sup> <span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer"> </span></span> </div>'; } echo ' <script type="text/javascript"> var flag_fields = \'name\'; </script>'; $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'flag_fields', 'name', false, true); echo ' <div class="clear"></div> </div> <label>' . $this->l('Group:') . ' </label> <div class="margin-form"> <select name="id_attribute_group" id="id_attribute_group" onchange="showAttributeColorGroup(\'id_attribute_group\', \'colorAttributeProperties\')">'; foreach ($attributes_groups as $attribute_group) { echo '<option value="' . $attribute_group['id_attribute_group'] . '"' . ($this->getFieldValue($obj, 'id_attribute_group') == $attribute_group['id_attribute_group'] ? ' selected="selected"' : '') . '>' . $attribute_group['name'] . '</option>'; } echo ' </select><sup> *</sup> </div> <script type="text/javascript" src="../js/jquery/jquery-colorpicker.js"></script> <div id="colorAttributeProperties" style="' . ((Validate::isLoadedObject($obj) and $obj->isColorAttribute()) ? 'display: block;' : 'display: none;') . '"> <label>' . $this->l('Color') . '</label> <div class="margin-form"> <input width="20px" type="color" data-hex="true" class="color mColorPickerInput" name="color" value="' . (Tools::getValue('color', $color) ? htmlentities(Tools::getValue('color', $color)) : '#000000') . '" /> <sup>*</sup> <p class="clear">' . $this->l('HTML colors only (e.g.,') . ' "lightblue", "#CC6600")</p> </div> <label>' . $this->l('Texture:') . ' </label> <div class="margin-form"> <input type="file" name="texture" /> <p>' . $this->l('Upload color texture from your computer') . '<br />' . $this->l('This will override the HTML color!') . '</p> </div> <label>' . $this->l('Current texture:') . ' </label> <div class="margin-form"> <p>' . (file_exists(_PS_IMG_DIR_ . $this->fieldImageSettings['dir'] . '/' . $obj->id . '.jpg') ? '<img src="../img/' . $this->fieldImageSettings['dir'] . '/' . $obj->id . '.jpg" alt="" title="" /> <a href="' . Tools::safeOutput($_SERVER['REQUEST_URI']) . '&deleteImage=1"><img src="../img/admin/delete.gif" alt="" title="' . $this->l('Delete') . '" />' . $this->l('Delete') . '</a>' : $this->l('None')) . '</p> </div> </div> ' . Module::hookExec('attributeForm', array('id_attribute' => $obj->id)) . ' <div class="margin-form"> <input type="submit" value="' . $this->l(' Save ') . '" name="submitAddattribute" class="button" /> </div> <div class="small"><sup>*</sup> ' . $this->l('Required field') . '</div> </fieldset> </form> <script> showAttributeColorGroup(\'id_attribute_group\', \'colorAttributeProperties\'); </script>'; }
protected function generateAttributeGroupData() { $delimiter = ';'; $line = array(); $titles = array(); $new_path = new Sampledatainstall(); $id_lang = $this->use_lang; $f = fopen($new_path->sendPath() . 'output/attribute_groups.vsc', 'w'); foreach ($this->attribute_groups_fields as $field => $array) { $titles[] = $array['label']; } fputcsv($f, $titles, $delimiter, '"'); $attribute_groups = AttributeGroup::getAttributesGroups($id_lang); if ($attribute_groups) { uasort($attribute_groups, array('SampleDataInstall', 'cmp')); foreach ($attribute_groups as $attribute_group) { foreach ($this->attribute_groups_fields as $field => $array) { $line[$field] = !Tools::isEmpty($attribute_group[$field]) ? $attribute_group[$field] : ''; } if (!$line[$field]) { $line[$field] = ''; } fputcsv($f, $line, $delimiter, '"'); } } fclose($f); }
private function _displayFormItemsSpecifics() { // Smarty $template_vars = array('id_tab' => Tools::safeOutput(Tools::getValue('id_tab')), 'controller' => Tools::getValue('controller'), 'tab' => Tools::getValue('tab'), 'configure' => Tools::getValue('configure'), 'tab_module' => Tools::getValue('tab_module'), 'module_name' => Tools::getValue('module_name'), 'token' => Tools::getValue('token'), 'ebay_token' => Configuration::get('EBAY_SECURITY_TOKEN'), '_module_dir_' => _MODULE_DIR_, 'ebay_categories' => EbayCategoryConfiguration::getEbayCategories(), 'id_lang' => $this->context->cookie->id_lang, '_path' => $this->_path, 'possible_attributes' => AttributeGroup::getAttributesGroups($this->context->cookie->id_lang), 'possible_features' => Feature::getFeatures($this->context->cookie->id_lang, true), 'date' => pSQL(date('Ymdhis')), 'conditions' => $this->_translatePSConditions(EbayCategoryConditionConfiguration::getPSConditions())); $this->smarty->assign($template_vars); return $this->display(dirname(__FILE__), '/views/templates/hook/formItemsSpecifics.tpl'); }
function displayFormAttributes($obj, $languages, $defaultLanguage) { global $currentIndex, $cookie; $attributeJs = array(); $attributes = Attribute::getAttributes((int) $cookie->id_lang, true); foreach ($attributes as $k => $attribute) { $attributeJs[$attribute['id_attribute_group']][$attribute['id_attribute']] = $attribute['name']; } $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); $attributes_groups = AttributeGroup::getAttributesGroups((int) $cookie->id_lang); $default_country = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT')); $images = Image::getImages((int) $cookie->id_lang, $obj->id); if ($obj->id) { echo ' <script type="text/javascript"> $(document).ready(function(){ $(\'#id_mvt_reason\').change(function(){ updateMvtStatus($(this).val()); }); updateMvtStatus($(this).val()); }); </script> <table cellpadding="5"> <tr> <td colspan="2"><b>' . $this->l('Add or modify combinations for this product') . '</b> - <a href="index.php?tab=AdminCatalog&id_product=' . $obj->id . '&id_category=' . (int) Tools::getValue('id_category') . '&attributegenerator&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/appearance.gif" alt="combinations_generator" class="middle" title="' . $this->l('Product combinations generator') . '" /> ' . $this->l('Product combinations generator') . '</a> </td> </tr> </table> <hr style="width:100%;" /><br /> <table cellpadding="5" style="width:100%"> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" valign="top">' . $this->l('Group:') . '</td> <td style="padding-bottom:5px;"><select name="attribute_group" id="attribute_group" style="width: 200px;" onchange="populate_attrs();">'; if (isset($attributes_groups)) { foreach ($attributes_groups as $k => $attribute_group) { if (isset($attributeJs[$attribute_group['id_attribute_group']])) { echo ' <option value="' . $attribute_group['id_attribute_group'] . '"> ' . htmlentities(stripslashes($attribute_group['name']), ENT_COMPAT, 'UTF-8') . ' </option>'; } } } echo ' </select></td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" valign="top">' . $this->l('Attribute:') . '</td> <td style="padding-bottom:5px;"><select name="attribute" id="attribute" style="width: 200px;"> <option value="0">---</option> </select> <script type="text/javascript" language="javascript">populate_attrs();</script> </td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" valign="top"> <input style="width: 140px; margin-bottom: 10px;" type="button" value="' . $this->l('Add') . '" class="button" onclick="add_attr();"/><br /> <input style="width: 140px;" type="button" value="' . $this->l('Delete') . '" class="button" onclick="del_attr()"/></td> <td align="left"> <select id="product_att_list" name="attribute_combinaison_list[]" multiple="multiple" size="4" style="width: 320px;"></select> </td> </tr> <tr><td colspan="2"><hr style="width:100%;" /></td></tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" id="attribute_reference" name="attribute_reference" value="" style="width: 130px; margin-right: 44px;" /> ' . $this->l('EAN13:') . '<input size="55" maxlength="13" type="text" id="attribute_ean13" name="attribute_ean13" value="" style="width: 110px; margin-left: 10px; margin-right: 44px;" /> ' . $this->l('UPC:') . '<input size="55" maxlength="12" type="text" id="attribute_upc" name="attribute_upc" value="" style="width: 110px; margin-left: 10px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#<span class="hint-pointer"> </span></span> </td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Supplier Reference:') . '</td> <td style="padding-bottom:5px;"> <input size="55" type="text" id="attribute_supplier_reference" name="attribute_supplier_reference" value="" style="width: 130px; margin-right: 44px;" /> ' . $this->l('Location:') . '<input size="55" type="text" id="attribute_location" name="attribute_location" value="" style="width: 101px; margin-left: 10px;" /> <span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#<span class="hint-pointer"> </span></span> </td> </tr> <tr><td colspan="2"><hr style="width:100%;" /></td></tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Wholesale price:') . '</td> <td style="padding-bottom:5px;">' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input type="text" size="6" name="attribute_wholesale_price" id="attribute_wholesale_price" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' (' . $this->l('overrides Wholesale price on Information tab') . ')</td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Impact on price:') . '</td> <td colspan="2" style="padding-bottom:5px;"> <select name="attribute_price_impact" id="attribute_price_impact" style="width: 140px;" onchange="check_impact(); calcImpactPriceTI();"> <option value="0">' . $this->l('None') . '</option> <option value="1">' . $this->l('Increase') . '</option> <option value="-1">' . $this->l('Reduction') . '</option> </select> <span id="span_impact"> ' . $this->l('of') . ' ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . ' <input type="text" size="6" name="attribute_price" id="attribute_price" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\'); calcImpactPriceTI();"/>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : ''); if ($default_country->display_tax_label) { echo ' ' . $this->l('(tax excl.)') . '<span ' . (Tax::excludeTaxeOption() ? 'style="display:none"' : '') . '> ' . $this->l('or') . ' ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . ' <input type="text" size="6" name="attribute_priceTI" id="attribute_priceTI" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\'); calcImpactPriceTE();"/>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' ' . $this->l('(tax incl.)') . '</span> ' . $this->l('final product price will be set to') . ' ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<span id="attribute_new_total_price">0.00</span>' . ($currency->format % 2 == 0 ? $currency->sign . ' ' : ''); } echo ' </span> </td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Impact on weight:') . '</td> <td colspan="2" style="padding-bottom:5px;"><select name="attribute_weight_impact" id="attribute_weight_impact" style="width: 140px;" onchange="check_weight_impact();"> <option value="0">' . $this->l('None') . '</option> <option value="1">' . $this->l('Increase') . '</option> <option value="-1">' . $this->l('Reduction') . '</option> </select> <span id="span_weight_impact"> ' . $this->l('of') . ' <input type="text" size="6" name="attribute_weight" id="attribute_weight" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . '</span></td> </tr> <tr id="tr_unit_impact"> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Impact on unit price :') . '</td> <td colspan="2" style="padding-bottom:5px;"><select name="attribute_unit_impact" id="attribute_unit_impact" style="width: 140px;" onchange="check_unit_impact();"> <option value="0">' . $this->l('None') . '</option> <option value="1">' . $this->l('Increase') . '</option> <option value="-1">' . $this->l('Reduction') . '</option> </select> <span id="span_unit_impact"> ' . $this->l('of') . ' ' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . ' <input type="text" size="6" name="attribute_unity" id="attribute_unity" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' / <span id="unity_third">' . $this->getFieldValue($obj, 'unity') . '</span> </span></td> </tr>'; if (Configuration::get('PS_USE_ECOTAX')) { echo ' <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Eco-tax:') . '</td> <td style="padding-bottom:5px;">' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input type="text" size="3" name="attribute_ecotax" id="attribute_ecotax" value="0.00" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' (' . $this->l('overrides Eco-tax on Information tab') . ')</td> </tr>'; } echo ' <tr id="initial_stock_attribute"> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" class="col-left">' . $this->l('Initial stock:') . '</td> <td><input type="text" name="attribute_quantity" size="3" maxlength="10" value="0"/></td> </tr> </tr> <tr id="stock_mvt_attribute" style="display:none;"> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" class="col-left">' . $this->l('Stock movement:') . '</td> <td style="padding-bottom:5px;"> <select id="id_mvt_reason" name="id_mvt_reason"> <option value="-1">--</option>'; $reasons = StockMvtReason::getStockMvtReasons((int) $cookie->id_lang); foreach ($reasons as $reason) { echo '<option rel="' . $reason['sign'] . '" value="' . $reason['id_stock_mvt_reason'] . '" ' . (Configuration::get('PS_STOCK_MVT_REASON_DEFAULT') == $reason['id_stock_mvt_reason'] ? 'selected="selected"' : '') . '>' . $reason['name'] . '</option>'; } echo '</select> <input type="text" name="attribute_mvt_quantity" size="3" maxlength="10" value="0"/> <span style="display:none;" id="mvt_sign"></span> <br /> <div class="hint clear" style="display: block;width: 70%;">' . $this->l('Choose the reason and enter the quantity that you want to increase or decrease in your stock') . '</div> </td> </tr> <tr> <td style="width:150px;vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;" class="col-left">' . $this->l('Minimum quantity:') . '</td> <td style="padding-bottom:5px;"> <input size="3" maxlength="10" name="attribute_minimal_quantity" id="attribute_minimal_quantity" type="text" value="' . ($this->getFieldValue($obj, 'attribute_minimal_quantity') ? $this->getFieldValue($obj, 'attribute_minimal_quantity') : 1) . '" /> <p>' . $this->l('The minimum quantity to buy this product (set to 1 to disable this feature)') . '</p> </td> </tr> <tr style="display:none;" id="attr_qty_stock"> <td style="width:150px">' . $this->l('Quantity in stock:') . '</td> <td style="padding-bottom:5px;"><b><span style="display:none;" id="attribute_quantity"></span></b></td> </tr> <tr><td colspan="2"><hr style="width:100%;" /></td></tr> <tr> <td style="width:150px">' . $this->l('Image:') . '</td> <td style="padding-bottom:5px;"> <ul id="id_image_attr">'; $i = 0; $imageType = ImageType::getByNameNType('small', 'products'); $imageWidth = (isset($imageType['width']) ? (int) $imageType['width'] : 64) + 25; foreach ($images as $image) { $imageObj = new Image($image['id_image']); echo '<li style="float: left; width: ' . $imageWidth . 'px;"><input type="checkbox" name="id_image_attr[]" value="' . (int) $image['id_image'] . '" id="id_image_attr_' . (int) $image['id_image'] . '" /> <label for="id_image_attr_' . (int) $image['id_image'] . '" style="float: none;"><img src="' . _THEME_PROD_DIR_ . $imageObj->getExistingImgPath() . '-small.jpg" alt="' . htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8') . '" title="' . htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8') . '" /></label></li>'; ++$i; } echo '</ul> <img id="pic" alt="" title="" style="display: none; width: 100px; height: 100px; float: left; border: 1px dashed #BBB; margin-left: 20px;" /> </td> </tr> <tr> <td style="width:150px">' . $this->l('Default:') . '<br /><br /></td> <td style="padding-bottom:5px;"> <input type="checkbox" name="attribute_default" id="attribute_default" value="1" /> ' . $this->l('Make this the default combination for this product') . '<br /><br /> </td> </tr> <tr> <td style="width:150px"> </td> <td style="padding-bottom:5px;"> <span style="float: left;"><input type="submit" name="submitProductAttribute" id="submitProductAttribute" value="' . $this->l('Add this combination') . '" class="button" onclick="attr_selectall(); this.form.action += \'&addproduct&tabs=3\';" /> </span> <span id="ResetSpan" style="float: left; margin-left: 8px; display: none;"> <input type="reset" name="ResetBtn" id="ResetBtn" onclick="init_elems(); getE(\'submitProductAttribute\').value = \'' . $this->l('Add this attributes group', __CLASS__, true) . '\'; getE(\'id_product_attribute\').value = 0; $(\'#ResetSpan\').slideToggle();" class="button" value="' . $this->l('Cancel modification') . '" /></span><span class="clear"></span> </td> </tr> <tr><td colspan="2"><hr style="width:100%;" /></td></tr> <tr> <td colspan="2"> <br /> <table border="0" cellpadding="0" cellspacing="0" class="table"> <tr> <th>' . $this->l('Attributes') . '</th> <th>' . $this->l('Impact') . '</th> <th>' . $this->l('Weight') . '</th> <th>' . $this->l('Reference') . '</th> <th>' . $this->l('EAN13') . '</th> <th>' . $this->l('UPC') . '</th> <th class="center">' . $this->l('Quantity') . '</th> <th class="center">' . $this->l('Actions') . '</th> </tr>'; if ($obj->id) { /* Build attributes combinaisons */ $combinaisons = $obj->getAttributeCombinaisons((int) $cookie->id_lang); $groups = array(); if (is_array($combinaisons)) { $combinationImages = $obj->getCombinationImages((int) $cookie->id_lang); foreach ($combinaisons as $k => $combinaison) { $combArray[$combinaison['id_product_attribute']]['wholesale_price'] = $combinaison['wholesale_price']; $combArray[$combinaison['id_product_attribute']]['price'] = $combinaison['price']; $combArray[$combinaison['id_product_attribute']]['weight'] = $combinaison['weight']; $combArray[$combinaison['id_product_attribute']]['unit_impact'] = $combinaison['unit_price_impact']; $combArray[$combinaison['id_product_attribute']]['reference'] = $combinaison['reference']; $combArray[$combinaison['id_product_attribute']]['supplier_reference'] = $combinaison['supplier_reference']; $combArray[$combinaison['id_product_attribute']]['ean13'] = $combinaison['ean13']; $combArray[$combinaison['id_product_attribute']]['upc'] = $combinaison['upc']; $combArray[$combinaison['id_product_attribute']]['attribute_minimal_quantity'] = $combinaison['minimal_quantity']; $combArray[$combinaison['id_product_attribute']]['location'] = $combinaison['location']; $combArray[$combinaison['id_product_attribute']]['quantity'] = $combinaison['quantity']; $combArray[$combinaison['id_product_attribute']]['id_image'] = isset($combinationImages[$combinaison['id_product_attribute']][0]['id_image']) ? $combinationImages[$combinaison['id_product_attribute']][0]['id_image'] : 0; $combArray[$combinaison['id_product_attribute']]['default_on'] = $combinaison['default_on']; $combArray[$combinaison['id_product_attribute']]['ecotax'] = $combinaison['ecotax']; $combArray[$combinaison['id_product_attribute']]['attributes'][] = array($combinaison['group_name'], $combinaison['attribute_name'], $combinaison['id_attribute']); if ($combinaison['is_color_group']) { $groups[$combinaison['id_attribute_group']] = $combinaison['group_name']; } } } $irow = 0; if (isset($combArray)) { foreach ($combArray as $id_product_attribute => $product_attribute) { $list = ''; $jsList = ''; /* In order to keep the same attributes order */ asort($product_attribute['attributes']); foreach ($product_attribute['attributes'] as $attribute) { $list .= addslashes(htmlspecialchars($attribute[0])) . ' - ' . addslashes(htmlspecialchars($attribute[1])) . ', '; $jsList .= '\'' . addslashes(htmlspecialchars($attribute[0])) . ' : ' . addslashes(htmlspecialchars($attribute[1])) . '\', \'' . $attribute[2] . '\', '; } $list = rtrim($list, ', '); $jsList = rtrim($jsList, ', '); $attrImage = $product_attribute['id_image'] ? new Image($product_attribute['id_image']) : false; echo ' <tr' . ($irow++ % 2 ? ' class="alt_row"' : '') . ($product_attribute['default_on'] ? ' style="background-color:#D1EAEF"' : '') . '> <td>' . stripslashes($list) . '</td> <td class="right">' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . $product_attribute['price'] . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '</td> <td class="right">' . $product_attribute['weight'] . Configuration::get('PS_WEIGHT_UNIT') . '</td> <td class="right">' . $product_attribute['reference'] . '</td> <td class="right">' . $product_attribute['ean13'] . '</td> <td class="right">' . $product_attribute['upc'] . '</td> <td class="center">' . $product_attribute['quantity'] . '</td> <td class="center"> <a style="cursor: pointer;"> <img src="../img/admin/edit.gif" alt="' . $this->l('Modify this combination') . '" onclick="javascript:fillCombinaison(\'' . $product_attribute['wholesale_price'] . '\', \'' . $product_attribute['price'] . '\', \'' . $product_attribute['weight'] . '\', \'' . $product_attribute['unit_impact'] . '\', \'' . $product_attribute['reference'] . '\', \'' . $product_attribute['supplier_reference'] . '\', \'' . $product_attribute['ean13'] . '\', \'' . $product_attribute['quantity'] . '\', \'' . ($attrImage ? $attrImage->id : 0) . '\', Array(' . $jsList . '), \'' . $id_product_attribute . '\', \'' . $product_attribute['default_on'] . '\', \'' . $product_attribute['ecotax'] . '\', \'' . $product_attribute['location'] . '\', \'' . $product_attribute['upc'] . '\', \'' . $product_attribute['attribute_minimal_quantity'] . '\'); calcImpactPriceTI();" /></a> ' . (!$product_attribute['default_on'] ? '<a href="' . $currentIndex . '&defaultProductAttribute&id_product_attribute=' . $id_product_attribute . '&id_product=' . $obj->id . '&' . (Tools::isSubmit('id_category') ? 'id_category=' . (int) Tools::getValue('id_category') . '&' : '&') . 'token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '"> <img src="../img/admin/asterisk.gif" alt="' . $this->l('Make this the default combination') . '" title="' . $this->l('Make this combination the default one') . '"></a>' : '') . ' <a href="' . $currentIndex . '&deleteProductAttribute&id_product_attribute=' . $id_product_attribute . '&id_product=' . $obj->id . '&' . (Tools::isSubmit('id_category') ? 'id_category=' . (int) Tools::getValue('id_category') . '&' : '&') . 'token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"> <img src="../img/admin/delete.gif" alt="' . $this->l('Delete this combination') . '" /></a></td> </tr>'; } echo '<tr><td colspan="7" align="center"><a href="' . $currentIndex . '&deleteAllProductAttributes&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminCatalog' . (int) Tab::getIdFromClassName('AdminCatalog') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');"><img src="../img/admin/delete.gif" alt="' . $this->l('Delete this combination') . '" /> ' . $this->l('Delete all combinations') . '</a></td></tr>'; } else { echo '<tr><td colspan="7" align="center"><i>' . $this->l('No combination yet') . '.</i></td></tr>'; } } echo ' </table> <br />' . $this->l('The row in blue is the default combination.') . ' <br /> ' . $this->l('A default combination must be designated for each product.') . ' </td> </tr> </table> <script type="text/javascript"> var impact = getE(\'attribute_price_impact\'); var impact2 = getE(\'attribute_weight_impact\'); var s_attr_group = document.getElementById(\'span_new_group\'); var s_attr_name = document.getElementById(\'span_new_attr\'); var s_impact = document.getElementById(\'span_impact\'); var s_impact2 = document.getElementById(\'span_weight_impact\'); init_elems(); </script> <hr style="width:100%;" /> <table cellpadding="5"> <tr> <td class="col-left"><b>' . $this->l('Color picker:') . '</b></td> <td style="padding-bottom:5px;"> <select name="id_color_default"> <option value="0">' . $this->l('Do not display') . '</option>'; foreach ($attributes_groups as $k => $attribute_group) { if (isset($groups[$attribute_group['id_attribute_group']])) { echo '<option value="' . (int) $attribute_group['id_attribute_group'] . '" ' . ((int) $attribute_group['id_attribute_group'] == (int) $obj->id_color_default ? 'selected="selected"' : '') . '>' . htmlentities(stripslashes($attribute_group['name']), ENT_COMPAT, 'UTF-8') . '</option>'; } } echo ' </select> <input type="submit" value="' . $this->l('OK') . '" name="submitAdd' . $this->table . 'AndStay" class="button" /> <a href="index.php?tab=AdminAttributesGroups&token=' . Tools::getAdminToken('AdminAttributesGroups' . (int) Tab::getIdFromClassName('AdminAttributesGroups') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/asterisk.gif" alt="" /> ' . $this->l('Color attribute management') . '</a> <p >' . $this->l('Activate the color choice by selecting a color attribute group.') . '</p> </td> </tr> </table>'; } else { echo '<b>' . $this->l('You must save this product before adding combinations') . '.</b>'; } }
/** * Display the BO html with smart templates */ public function _displayForm() { global $smarty, $cookie; $smarty->assign(array('oModule' => $this, 'cookie' => $cookie)); $this->_html .= '<div id="prediggo_conf">'; // Display errors $smarty->assign(array('aPrediggoWarnings' => $this->_warnings, 'aPrediggoConfirmations' => $this->_confirmations, 'aPrediggoErrors' => $this->_errors)); $this->_html .= $this->display(__FILE__, 'bo_errors.tpl'); $this->_html .= $this->display(__FILE__, 'bo_tabs.tpl'); // Display Main Configuration management $smarty->assign(array('formAction' => Tools::safeOutput($_SERVER['REQUEST_URI']), 'oPrediggoConfig' => $this->oPrediggoConfig, 'aLanguages' => Language::getLanguages(false))); $this->_html .= $this->display(__FILE__, 'bo_main_conf.tpl'); // Get Export Attribute manager $aPrediggoAttributesGroups = explode(',', $this->oPrediggoExportConfig->attributes_groups_ids); $aPrediggoFeatures = explode(',', $this->oPrediggoExportConfig->features_ids); $smarty->assign(array('oPrediggoExportConfig' => $this->oPrediggoExportConfig, 'aPrediggoAttributesGroups' => $aPrediggoAttributesGroups, 'aPrediggoFeatures' => $aPrediggoFeatures, 'aGroupAttributes' => AttributeGroup::getAttributesGroups((int) $cookie->id_lang), 'aFeatures' => Feature::getFeatures((int) $cookie->id_lang))); $sAttributeManager = $this->display(__FILE__, 'bo_export_attribute_manager.tpl'); // Get Recommendations black list $aPrediggoProductsNotRecommendable = $this->oPrediggoExportConfig->products_ids_not_recommendable; if (!empty($aPrediggoProductsNotRecommendable)) { $aPrediggoProductsNotRecommendable = explode(',', $aPrediggoProductsNotRecommendable); foreach ($aPrediggoProductsNotRecommendable as $k => $iID) { $aPrediggoProductsNotRecommendable[$k] = new Product((int) $iID, false, (int) $cookie->id_lang); } } // Get Search black list $aPrediggoProductsNotSearchable = $this->oPrediggoExportConfig->products_ids_not_searchable; if (!empty($aPrediggoProductsNotSearchable)) { $aPrediggoProductsNotSearchable = explode(',', $aPrediggoProductsNotSearchable); foreach ($aPrediggoProductsNotSearchable as $k => $iID) { $aPrediggoProductsNotSearchable[$k] = new Product((int) $iID, false, (int) $cookie->id_lang); } } $smarty->assign(array('aPrediggoProductsNotRecommendable' => $aPrediggoProductsNotRecommendable, 'aPrediggoProductsNotSearchable' => $aPrediggoProductsNotSearchable)); $sBackListManager = $this->display(__FILE__, 'bo_black_lists.tpl'); // Display Export Configuration management $smarty->assign(array('sAttributeManager' => $sAttributeManager, 'sBackListManager' => $sBackListManager, 'sExportRepositoryPath' => $this->oDataExtractorController->getRepositoryPath(), 'sCronFilePath' => Tools::getShopDomain(true) . str_replace(_PS_ROOT_DIR_ . '/', __PS_BASE_URI__, $this->_path) . 'cron_export.php')); $this->_html .= $this->display(__FILE__, 'bo_export_conf.tpl'); // Display Recommendations Configuration management $smarty->assign(array('oPrediggoRecommendationConfig' => $this->oPrediggoRecommendationConfig)); $this->_html .= $this->display(__FILE__, 'bo_recommendation_conf.tpl'); // Display Recommendations Configuration management $smarty->assign(array('oPrediggoSearchConfig' => $this->oPrediggoSearchConfig)); $this->_html .= $this->display(__FILE__, 'bo_search_conf.tpl'); $this->_html .= '</div>'; }
public function attributeImport($offset = false, $limit = false, &$crossStepsVariables = false, $validateOnly = false) { $default_language = Configuration::get('PS_LANG_DEFAULT'); $groups = array(); if ($crossStepsVariables !== false && array_key_exists('groups', $crossStepsVariables)) { $groups = $crossStepsVariables['groups']; } foreach (AttributeGroup::getAttributesGroups($default_language) as $group) { $groups[$group['name']] = (int) $group['id_attribute_group']; } $attributes = array(); if ($crossStepsVariables !== false && array_key_exists('attributes', $crossStepsVariables)) { $attributes = $crossStepsVariables['attributes']; } foreach (Attribute::getAttributes($default_language) as $attribute) { $attributes[$attribute['attribute_group'] . '_' . $attribute['name']] = (int) $attribute['id_attribute']; } $this->receiveTab(); $handle = $this->openCsvFile($offset); if (!$handle) { return false; } AdminImportController::setLocale(); $regenerate = Tools::getValue('regenerate'); $shop_is_feature_active = Shop::isFeatureActive(); $line_count = 0; for ($current_line = 0; ($line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator)) && (!$limit || $current_line < $limit); $current_line++) { $line_count++; if ($this->convert) { $line = $this->utf8EncodeArray($line); } if (count($line) == 1 && $line[0] == null) { $this->warnings[] = $this->l('There is an empty row in the file that won\'t be imported.'); continue; } $info = AdminImportController::getMaskedRow($line); $info = array_map('trim', $info); $this->attributeImportOne($info, $default_language, $groups, $attributes, $regenerate, $shop_is_feature_active, $validateOnly); } $this->closeCsvFile($handle); if ($crossStepsVariables !== false) { $crossStepsVariables['groups'] = $groups; $crossStepsVariables['attributes'] = $attributes; } return $line_count; }
public function displayForm($isMainTab = true) { global $currentIndex, $cookie; parent::displayForm(); $jsAttributes = self::displayAndReturnAttributeJs(); $attributesGroups = AttributeGroup::getAttributesGroups((int) $cookie->id_lang); $this->product = new Product((int) Tools::getValue('id_product')); // JS Init echo '<script type="text/javascript"> i18n_tax_exc = "' . $this->l('Tax Excl.:') . '"; i18n_tax_inc = "' . $this->l('Tax Incl.:') . '"; var product_tax = "' . Tax::getProductTaxRate($this->product->id, NULL) . '"; function calcPrice(element, element_has_tax) { name = element.attr("name"); var element_price = element.val().replace(/,/g, "."); var other_element_price = "0"; if (!isNaN(element_price) && element_price > 0) { if (element_has_tax) other_element_price = parseFloat(element_price / ((product_tax / 100) + 1)); else other_element_price = ps_round(parseFloat(element_price * ((product_tax / 100) + 1)), 2); } $("#related_to_"+name).val(other_element_price); } $(document).ready(function() { $(".price_impact").each(function() { calcPrice($(this), false); }); }); </script>'; if (isset($_POST['generate']) and !sizeof($this->_errors)) { echo ' <div class="module_confirmation conf confirm"> <img src="../img/admin/ok.gif" alt="" title="" style="margin-right:5px; float:left;" /> ' . sizeof($this->combinations) . ' ' . $this->l('product(s) successfully created.') . ' </div>'; } echo ' <script type="text/javascript" src="../js/attributesBack.js"></script> <form enctype="multipart/form-data" method="post" id="generator" action="' . $currentIndex . '&&id_product=' . (int) Tools::getValue('id_product') . '&id_category=' . (int) Tools::getValue('id_category') . '&attributegenerator&token=' . Tools::getValue('token') . '"> <fieldset style="margin-bottom: 35px;"><legend><img src="../img/admin/asterisk.gif" />' . $this->l('Attributes generator') . '</legend>' . $this->l('Add or modify attributes for product:') . ' <b>' . $this->product->name[$cookie->id_lang] . '</b> <br /><br /> '; echo ' <div style="padding-top:10px; float: left; width: 570px;"> <div style="float:left;"> <label>' . $this->l('Quantity') . '</label> <div class="margin-form"> <input type="text" size="20" name="quantity" value="0"/> </div> <label>' . $this->l('Reference') . '</label> <div class="margin-form"> <input type="text" size="20" name="reference" value="' . $this->product->reference . '"/> </div> </div> <div style="float:left; text-align:center; margin-left:20px;"> <input type="submit" class="button" style="margin-bottom:5px;" name="generate" value="' . $this->l('Generate') . '" /><br /> <input type="submit" class="button" name="back" value="' . $this->l('Back to product') . '" /> </div> <br style="clear:both;" /> <div style="margin-top: 15px;">'; self::displayGroupeTable($jsAttributes, $attributesGroups); echo ' </div> </div> <div style="float: left; margin-left: 60px;"> '; self::displayGroupSelect($jsAttributes, $attributesGroups); echo ' <div> <p style="text-align: center;"> <input class="button" type="button" style="margin: 0 0 10px 20px;" value="' . $this->l('Add') . '" class="button" onclick="add_attr_multiple();" /> <input class="button" type="button" style="margin: 0 0 10px 20px;" value="' . $this->l('Delete') . '" class="button" onclick="del_attr_multiple();" /><br /> <input type="submit" class="button" name="back" value="' . $this->l('Back to product') . '" /> </p> </div> </div> <br /> </fieldset> </form>'; }
public function renderFormAttributes() { $attributes_groups = AttributeGroup::getAttributesGroups($this->context->language->id); $this->table = 'attribute'; $this->identifier = 'id_attribute'; $this->fields_form = array('legend' => array('title' => $this->l('Values'), 'image' => '../img/admin/asterisk.gif'), 'input' => array(array('type' => 'select', 'label' => $this->l('Attribute type:'), 'name' => 'id_attribute_group', 'required' => true, 'options' => array('query' => $attributes_groups, 'id' => 'id_attribute_group', 'name' => 'name'), 'desc' => $this->l('Choose the type of the attribute')), array('type' => 'text', 'label' => $this->l('Value:'), 'name' => 'name', 'lang' => true, 'size' => 33, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'))); if (Shop::isFeatureActive()) { // We get all associated shops for all attribute groups, because we will disable group shops // for attributes that the selected attribute group don't support $sql = 'SELECT id_attribute_group, id_shop FROM ' . _DB_PREFIX_ . 'attribute_group_shop'; $associations = array(); foreach (Db::getInstance()->executeS($sql) as $row) { $associations[$row['id_attribute_group']][] = $row['id_shop']; } $this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso', 'values' => Shop::getTree()); } else { $associations = array(); } $this->fields_form['shop_associations'] = Tools::jsonEncode($associations); $this->fields_form['input'][] = array('type' => 'color', 'label' => $this->l('Color:'), 'name' => 'color', 'size' => 33, 'desc' => $this->l('Choose a color with the color picker, or enter an HTML color (e.g. "lightblue", "#CC6600")')); $this->fields_form['input'][] = array('type' => 'file', 'label' => $this->l('Texture:'), 'name' => 'texture', 'desc' => array($this->l('Upload color texture from your computer'), $this->l('This will override the HTML color!'))); $this->fields_form['input'][] = array('type' => 'current_texture', 'label' => $this->l('Current texture:'), 'name' => 'current_texture'); $this->fields_form['input'][] = array('type' => 'closediv', 'name' => ''); $this->fields_form['submit'] = array('title' => $this->l('Save '), 'class' => 'button'); // Override var of Controller $this->table = 'attribute'; $this->className = 'Attribute'; $this->identifier = 'id_attribute'; $this->lang = true; $this->tpl_folder = 'attributes/'; // Create object Attribute if (!($obj = new Attribute((int) Tools::getValue($this->identifier)))) { return; } $str_attributes_groups = ''; foreach ($attributes_groups as $attribute_group) { $str_attributes_groups .= '"' . $attribute_group['id_attribute_group'] . '" : ' . ($attribute_group['group_type'] == 'color' ? '1' : '0') . ', '; } $image = '../img/' . $this->fieldImageSettings['dir'] . '/' . (int) $obj->id . '.jpg'; $this->tpl_form_vars = array('strAttributesGroups' => $str_attributes_groups, 'colorAttributeProperties' => Validate::isLoadedObject($obj) && $obj->isColorAttribute(), 'imageTextureExists' => file_exists(_PS_IMG_DIR_ . $this->fieldImageSettings['dir'] . '/' . (int) $obj->id . '.jpg'), 'imageTexture' => $image, 'imageTextureUrl' => Tools::safeOutput($_SERVER['REQUEST_URI']) . '&deleteImage=1'); return parent::renderForm(); }
public function attributeImport() { $default_language = Configuration::get('PS_LANG_DEFAULT'); $groups = array(); foreach (AttributeGroup::getAttributesGroups($default_language) as $group) { $groups[$group['name']] = (int) $group['id_attribute_group']; } $attributes = array(); foreach (Attribute::getAttributes($default_language) as $attribute) { $attributes[$attribute['attribute_group'] . '_' . $attribute['name']] = (int) $attribute['id_attribute']; } $this->receiveTab(); $handle = $this->openCsvFile(); AdminImportController::setLocale(); for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) { if (count($line) == 1 && empty($line[0])) { continue; } if (Tools::getValue('convert')) { $line = $this->utf8EncodeArray($line); } $info = AdminImportController::getMaskedRow($line); $info = array_map('trim', $info); AdminImportController::setDefaultValues($info); if (!Shop::isFeatureActive()) { $info['shop'] = 1; } elseif (!isset($info['shop']) || empty($info['shop'])) { $info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID()); } // Get shops for each attributes $info['shop'] = explode($this->multiple_value_separator, $info['shop']); $id_shop_list = array(); foreach ($info['shop'] as $shop) { if (!is_numeric($shop)) { $id_shop_list[] = Shop::getIdByName($shop); } else { $id_shop_list[] = $shop; } } if (isset($info['id_product'])) { $product = new Product((int) $info['id_product'], false, $default_language); } else { continue; } $id_image = null; //delete existing images if "delete_existing_images" is set to 1 if (array_key_exists('delete_existing_images', $info) && $info['delete_existing_images'] && !isset($this->cache_image_deleted[(int) $product->id])) { $product->deleteImages(); $this->cache_image_deleted[(int) $product->id] = true; } if (isset($info['image_url']) && $info['image_url']) { $product_has_images = (bool) Image::getImages($this->context->language->id, $product->id); $url = $info['image_url']; $image = new Image(); $image->id_product = (int) $product->id; $image->position = Image::getHighestPosition($product->id) + 1; $image->cover = !$product_has_images ? true : false; $field_error = $image->validateFields(UNFRIENDLY_ERROR, true); $lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true); if ($field_error === true && $lang_field_error === true && $image->add()) { $image->associateTo($id_shop_list); if (!AdminImportController::copyImg($product->id, $image->id, $url)) { $this->warnings[] = sprintf(Tools::displayError('Error copying image: %s'), $url); $image->delete(); } else { $id_image = array($image->id); } } else { $this->warnings[] = sprintf(Tools::displayError('%s cannot be saved'), isset($image->id_product) ? ' (' . $image->id_product . ')' : ''); $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . mysql_error(); } } elseif (isset($info['image_position']) && $info['image_position']) { $images = $product->getImages($default_language); if ($images) { foreach ($images as $row) { if ($row['position'] == (int) $info['image_position']) { $id_image = array($row['id_image']); break; } } } if (!$id_image) { $this->warnings[] = sprintf(Tools::displayError('No image was found for combination with id_product = %s and image position = %s.'), $product->id, (int) $info['image_position']); } } $id_attribute_group = 0; // groups $groups_attributes = array(); if (isset($info['group'])) { foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) { $tab_group = explode(':', $group); $group = trim($tab_group[0]); if (!isset($tab_group[1])) { $type = 'select'; } else { $type = trim($tab_group[1]); } // sets group $groups_attributes[$key]['group'] = $group; // if position is filled if (isset($tab_group[2])) { $position = trim($tab_group[2]); } else { $position = false; } if (!isset($groups[$group])) { $obj = new AttributeGroup(); $obj->is_color_group = false; $obj->group_type = pSQL($type); $obj->name[$default_language] = $group; $obj->public_name[$default_language] = $group; $obj->position = !$position ? AttributeGroup::getHigherPosition() + 1 : $position; if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { $obj->add(); $obj->associateTo($id_shop_list); $groups[$group] = $obj->id; } else { $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''); } // fils groups attributes $id_attribute_group = $obj->id; $groups_attributes[$key]['id'] = $id_attribute_group; } else { $id_attribute_group = $groups[$group]; $groups_attributes[$key]['id'] = $id_attribute_group; } } } // inits attribute $id_product_attribute = 0; $id_product_attribute_update = false; $attributes_to_add = array(); // for each attribute if (isset($info['attribute'])) { foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute) { $tab_attribute = explode(':', $attribute); $attribute = trim($tab_attribute[0]); // if position is filled if (isset($tab_attribute[1])) { $position = trim($tab_attribute[1]); } else { $position = false; } if (isset($groups_attributes[$key])) { $group = $groups_attributes[$key]['group']; if (!isset($attributes[$group . '_' . $attribute]) && count($groups_attributes[$key]) == 2) { $id_attribute_group = $groups_attributes[$key]['id']; $obj = new Attribute(); // sets the proper id (corresponding to the right key) $obj->id_attribute_group = $groups_attributes[$key]['id']; $obj->name[$default_language] = str_replace('\\n', '', str_replace('\\r', '', $attribute)); $obj->position = !$position && isset($groups[$group]) ? Attribute::getHigherPosition($groups[$group]) + 1 : $position; if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { $obj->add(); $obj->associateTo($id_shop_list); $attributes[$group . '_' . $attribute] = $obj->id; } else { $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''); } } $info['minimal_quantity'] = isset($info['minimal_quantity']) && $info['minimal_quantity'] ? (int) $info['minimal_quantity'] : 1; $info['wholesale_price'] = str_replace(',', '.', $info['wholesale_price']); $info['price'] = str_replace(',', '.', $info['price']); $info['ecotax'] = str_replace(',', '.', $info['ecotax']); $info['weight'] = str_replace(',', '.', $info['weight']); // if a reference is specified for this product, get the associate id_product_attribute to UPDATE if (isset($info['reference']) && !empty($info['reference'])) { $id_product_attribute = Combination::getIdByReference($product->id, strval($info['reference'])); // updates the attribute if ($id_product_attribute) { // gets all the combinations of this product $attribute_combinations = $product->getAttributeCombinations($default_language); foreach ($attribute_combinations as $attribute_combination) { if ($id_product_attribute && in_array($id_product_attribute, $attribute_combination)) { $product->updateAttribute($id_product_attribute, (double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, (double) $info['ecotax'], $id_image, strval($info['reference']), strval($info['ean13']), (int) $info['default_on'], 0, strval($info['upc']), (int) $info['minimal_quantity'], 0, null, $id_shop_list); $id_product_attribute_update = true; } } } } // if no attribute reference is specified, creates a new one if (!$id_product_attribute) { $id_product_attribute = $product->addCombinationEntity((double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, (double) $info['ecotax'], (int) $info['quantity'], $id_image, strval($info['reference']), 0, strval($info['ean13']), (int) $info['default_on'], 0, strval($info['upc']), (int) $info['minimal_quantity'], $id_shop_list); } // fills our attributes array, in order to add the attributes to the product_attribute afterwards if (isset($attributes[$group . '_' . $attribute])) { $attributes_to_add[] = (int) $attributes[$group . '_' . $attribute]; } // after insertion, we clean attribute position and group attribute position $obj = new Attribute(); $obj->cleanPositions((int) $id_attribute_group, false); AttributeGroup::cleanPositions(); } } } $product->checkDefaultAttributes(); if (!$product->cache_default_attribute) { Product::updateDefaultAttribute($product->id); } if ($id_product_attribute) { // now adds the attributes in the attribute_combination table if ($id_product_attribute_update) { Db::getInstance()->execute(' DELETE FROM ' . _DB_PREFIX_ . 'product_attribute_combination WHERE id_product_attribute = ' . (int) $id_product_attribute); } foreach ($attributes_to_add as $attribute_to_add) { Db::getInstance()->execute(' INSERT IGNORE INTO ' . _DB_PREFIX_ . 'product_attribute_combination (id_attribute, id_product_attribute) VALUES (' . (int) $attribute_to_add . ',' . (int) $id_product_attribute . ')'); } StockAvailable::setQuantity($product->id, $id_product_attribute, (int) $info['quantity']); } } $this->closeCsvFile($handle); }
public function getContent() { $this->html = ''; if (Tools::isSubmit('submitNetEven')) { if (Tools::getValue('NETEVEN_LOGIN') && Tools::getValue('NETEVEN_PASSWORD')) { Gateway::updateConfig('NETEVEN_LOGIN', Tools::getValue('NETEVEN_LOGIN')); Gateway::updateConfig('NETEVEN_PASSWORD', Tools::getValue('NETEVEN_PASSWORD')); Gateway::updateConfig('COMMENT', Tools::getValue('COMMENT')); Gateway::updateConfig('DEFAULT_BRAND', Tools::getValue('DEFAULT_BRAND')); Gateway::updateConfig('IMAGE_TYPE_NAME', Tools::getValue('IMAGE_TYPE_NAME')); Gateway::updateConfig('SYNCHRONISATION_ORDER', (int) Tools::getValue('SYNCHRONISATION_ORDER')); Gateway::updateConfig('SYNCHRONISATION_PRODUCT', (int) Tools::getValue('SYNCHRONISATION_PRODUCT')); Gateway::updateConfig('TYPE_SKU', (string) Tools::getValue('TYPE_SKU')); $this->html .= $this->displayConfirmation($this->l('Les paramètres ont bien été mis à jour')); } else { $this->html .= $this->displayError($this->l('Les login et mot de passe NetEven sont obligatoire')); } } elseif (Tools::isSubmit('submitNetEvenShipping')) { Gateway::updateConfig('SHIPPING_DELAY', Tools::getValue('SHIPPING_DELAY')); Gateway::updateConfig('SHIPPING_PRICE_LOCAL', Tools::getValue('SHIPPING_PRICE_LOCAL')); Gateway::updateConfig('SHIPPING_PRICE_INTERNATIONAL', Tools::getValue('SHIPPING_PRICE_INTERNATIONAL')); Gateway::updateConfig('SHIPPING_BY_PRODUCT', (int) Tools::getValue('SHIPPING_BY_PRODUCT')); Gateway::updateConfig('SHIPPING_BY_PRODUCT_FIELDNAME', Tools::getValue('SHIPPING_BY_PRODUCT_FIELDNAME')); Gateway::updateConfig('SHIPPING_CARRIER_FRANCE', Tools::getValue('SHIPPING_CARRIER_FRANCE')); Gateway::updateConfig('SHIPPING_ZONE_FRANCE', Tools::getValue('SHIPPING_ZONE_FRANCE')); Gateway::updateConfig('SHIPPING_CARRIER_INTERNATIONAL', Tools::getValue('SHIPPING_CARRIER_INTERNATIONAL')); Gateway::updateConfig('SHIPPING_ZONE_INTERNATIONAL', Tools::getValue('SHIPPING_ZONE_INTERNATIONAL')); $this->html .= $this->displayConfirmation($this->l('Les paramètres de livraison ont bien été mis à jour')); } elseif (Tools::isSubmit('submitDev')) { Gateway::updateConfig('NETEVEN_URL', Tools::getValue('NETEVEN_URL')); Gateway::updateConfig('NETEVEN_NS', Tools::getValue('NETEVEN_NS')); Gateway::updateConfig('MAIL_LIST_ALERT', Tools::getValue('MAIL_LIST_ALERT')); Gateway::updateConfig('DEBUG', (int) Tools::getValue('DEBUG')); Gateway::updateConfig('SEND_REQUEST_BY_EMAIL', (int) Tools::getValue('SEND_REQUEST_BY_EMAIL')); $this->html .= $this->displayConfirmation($this->l('Les paramètres de maintenance ont bien été mis à jour')); } elseif (Tools::isSubmit('submitCustomizableFeilds')) { $customizable_field_name = Tools::getValue('customizable_field_name'); $customizable_field_value = Tools::getValue('customizable_field_value'); $customizable_string = ''; foreach ($customizable_field_name as $key => $value) { if (!$customizable_field_name[$key] || !$customizable_field_value[$key]) { continue; } if ($customizable_string) { $customizable_string .= '¤'; } $customizable_string .= $customizable_field_name[$key] . '|' . $customizable_field_value[$key]; } Gateway::updateConfig('CUSTOMIZABLE_FIELDS', $customizable_string); } // Lists of order status $order_states = OrderState::getOrderStates((int) $this->context->cookie->id_lang); // Lists of features $features = Feature::getFeatures((int) $this->context->cookie->id_lang); // Lists of attribute groups $attribute_groups = AttributeGroup::getAttributesGroups((int) $this->context->cookie->id_lang); $neteven_features = Db::getInstance()->ExecuteS('SELECT * FROM `' . _DB_PREFIX_ . 'orders_gateway_feature`'); $neteven_feature_categories = array(); foreach ($neteven_features as $neteven_feature) { if (!isset($neteven_feature_categories[$neteven_feature['category']])) { $neteven_feature_categories[$neteven_feature['category']] = array(); } $neteven_feature_categories[$neteven_feature['category']][] = $neteven_feature; } if ($this->getSOAP()) { $this->html .= $this->displayForm($order_states, $features, $attribute_groups, $neteven_feature_categories); } else { $this->html .= $this->displayError($this->l('This module requires the SOAP extension to run')); } return $this->html; }
public function initContentForCombinations() { ${${"GLOBALS"}["vmqqtmkyw"]} = $this->object; if (!Combination::isFeatureActive()) { $this->displayWarning($this->getMessage("This feature has been disabled, you can activate this feature at this page:") . $this->getMessage("link to Performances")); return; } ${"GLOBALS"}["weevwwkl"] = "product"; if (Validate::isLoadedObject(${${"GLOBALS"}["weevwwkl"]})) { self::$smarty->assign("country_display_tax_label", $this->context->country->display_tax_label); $zsahvowoo = "lang"; self::$smarty->assign("tax_exclude_taxe_option", Tax::excludeTaxeOption()); self::$smarty->assign("id_tax_rules_group", $product->id_tax_rules_group); self::$smarty->assign("tax_rules_groups", TaxRulesGroup::getTaxRulesGroups(true)); ${$zsahvowoo} = new Language($this->id_language); self::$smarty->assign("iso_code", $lang->iso_code); self::$smarty->assign("combinationImagesJs", $this->getCombinationImagesJs()); if ($product->is_virtual) { $tpkpvyor = "product"; self::$smarty->assign("product", ${$tpkpvyor}); $this->displayWarning($this->getMessage("A virtual product cannot have combinations.")); } else { ${"GLOBALS"}["qqjbnscylsi"] = "attribute_js"; ${"GLOBALS"}["nqxaoftbn"] = "attribute"; $bcesaxqdqqq = "images"; ${"GLOBALS"}["zcxmuajd"] = "ps_stock_mvt_reason_default"; $vmytjghdfi = "attribute_js"; $nrkrfhirkx = "attributes"; ${${"GLOBALS"}["qqjbnscylsi"]} = array(); $cappytc = "k"; ${"GLOBALS"}["jyaoxpe"] = "attribute"; ${$nrkrfhirkx} = Attribute::getAttributes($this->context->language->id, true); foreach (${${"GLOBALS"}["ecblflvypvt"]} as ${$cappytc} => ${${"GLOBALS"}["jyaoxpe"]}) { ${$vmytjghdfi}[${${"GLOBALS"}["iixdipeiyldv"]}["id_attribute_group"]][${${"GLOBALS"}["iixdipeiyldv"]}["id_attribute"]] = ${${"GLOBALS"}["nqxaoftbn"]}["name"]; } ${"GLOBALS"}["higiwiyuxd"] = "k"; ${${"GLOBALS"}["sxexnhlq"]} = new Currency((int) Configuration::get("PS_CURRENCY_DEFAULT")); self::$smarty->assign("attributeJs", ${${"GLOBALS"}["xenfvrjowsy"]}); self::$smarty->assign("attributes_groups", AttributeGroup::getAttributesGroups($this->context->language->id)); self::$smarty->assign("currency", ${${"GLOBALS"}["sxexnhlq"]}); ${"GLOBALS"}["xzqtsdnlkv"] = "images"; ${$bcesaxqdqqq} = Image::getImages($this->context->language->id, $product->id); self::$smarty->assign("tax_exclude_option", Tax::excludeTaxeOption()); $rbxbrbxg = "product"; self::$smarty->assign("ps_weight_unit", Configuration::get("PS_WEIGHT_UNIT")); self::$smarty->assign("ps_use_ecotax", Configuration::get("PS_USE_ECOTAX")); self::$smarty->assign("field_value_unity", $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "unity")); ${"GLOBALS"}["vpcuib"] = "image_type"; self::$smarty->assign("reasons", ${${"GLOBALS"}["nqegxbae"]} = StockMvtReason::getStockMvtReasons($this->context->language->id)); self::$smarty->assign("ps_stock_mvt_reason_default", ${${"GLOBALS"}["zcxmuajd"]} = Configuration::get("PS_STOCK_MVT_REASON_DEFAULT")); self::$smarty->assign("minimal_quantity", $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "minimal_quantity") ? $this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "minimal_quantity") : 1); self::$smarty->assign("available_date", $this->getFieldValue(${$rbxbrbxg}, "available_date") != 0 ? stripslashes(htmlentities(Tools::displayDate($this->getFieldValue(${${"GLOBALS"}["vmqqtmkyw"]}, "available_date"), version_compare(_PS_VERSION_, "1.5.5", ">=") ? null : $this->context->language->id))) : "0000-00-00"); ${${"GLOBALS"}["tqkkuicfgax"]} = 0; ${"GLOBALS"}["ucamhp"] = "product"; self::$smarty->assign("imageType", ImageType::getByNameNType("small_default", "products")); self::$smarty->assign("imageWidth", (isset(${${"GLOBALS"}["rvkjjxqs"]}["width"]) ? (int) ${${"GLOBALS"}["vpcuib"]}["width"] : 64) + 25); foreach (${${"GLOBALS"}["xzqtsdnlkv"]} as ${${"GLOBALS"}["higiwiyuxd"]} => ${${"GLOBALS"}["inpuwydsyk"]}) { $cshrlmyryz = "image"; ${${"GLOBALS"}["dhvuermstcbs"]}[${${"GLOBALS"}["qtxqhylrbsm"]}]["obj"] = new Image(${$cshrlmyryz}["id_image"]); $kcvbkys = "i"; ++${$kcvbkys}; } self::$smarty->assign("images", ${${"GLOBALS"}["dhvuermstcbs"]}); self::$smarty->assign(array("combinationArray" => $this->getCombinations(${${"GLOBALS"}["ucamhp"]}, ${${"GLOBALS"}["sxexnhlq"]}), "product" => ${${"GLOBALS"}["vmqqtmkyw"]}, "id_category" => $product->getDefaultCategory(), "token_generator" => "tokengenerator", "combination_exists" => Shop::isFeatureActive() && Shop::getContextShopGroup()->share_stock && count(AttributeGroup::getAttributesGroups($this->context->language->id)) > 0)); } } else { self::$smarty->assign("product", ${${"GLOBALS"}["vmqqtmkyw"]}); $this->displayWarning($this->getMessage("You must save this product before adding combinations.")); } }
public function attributeImport() { $default_language = Configuration::get('PS_LANG_DEFAULT'); $groups = array(); foreach (AttributeGroup::getAttributesGroups($default_language) as $group) { $groups[$group['name']] = (int) $group['id_attribute_group']; } $attributes = array(); foreach (Attribute::getAttributes($default_language) as $attribute) { $attributes[$attribute['attribute_group'] . '_' . $attribute['name']] = (int) $attribute['id_attribute']; } $this->receiveTab(); $handle = $this->openCsvFile(); AdminImportController::setLocale(); for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) { if (count($line) == 1 && empty($line[0])) { continue; } if (Tools::getValue('convert')) { $line = $this->utf8EncodeArray($line); } $info = AdminImportController::getMaskedRow($line); $info = array_map('trim', $info); AdminImportController::setDefaultValues($info); if (!Shop::isFeatureActive()) { $info['shop'] = 1; } elseif (!isset($info['shop']) || empty($info['shop'])) { $info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID()); } // Get shops for each attributes $info['shop'] = explode($this->multiple_value_separator, $info['shop']); $id_shop_list = array(); if (is_array($info['shop']) && count($info['shop'])) { foreach ($info['shop'] as $shop) { if (!empty($shop) && !is_numeric($shop)) { $id_shop_list[] = Shop::getIdByName($shop); } elseif (!empty($shop)) { $id_shop_list[] = $shop; } } } if (isset($info['id_product']) && $info['id_product']) { $product = new Product((int) $info['id_product'], false, $default_language); } elseif (Tools::getValue('match_ref') && isset($info['product_reference']) && $info['product_reference']) { $datas = Db::getInstance()->getRow(' SELECT p.`id_product` FROM `' . _DB_PREFIX_ . 'product` p ' . Shop::addSqlAssociation('product', 'p') . ' WHERE p.`reference` = "' . pSQL($info['product_reference']) . '" '); if (isset($datas['id_product']) && $datas['id_product']) { $product = new Product((int) $datas['id_product'], false, $default_language); } } else { continue; } $id_image = array(); //delete existing images if "delete_existing_images" is set to 1 if (array_key_exists('delete_existing_images', $info) && $info['delete_existing_images'] && !isset($this->cache_image_deleted[(int) $product->id])) { $product->deleteImages(); $this->cache_image_deleted[(int) $product->id] = true; } if (isset($info['image_url']) && $info['image_url']) { $info['image_url'] = explode(',', $info['image_url']); if (is_array($info['image_url']) && count($info['image_url'])) { foreach ($info['image_url'] as $url) { $url = trim($url); $product_has_images = (bool) Image::getImages($this->context->language->id, $product->id); $image = new Image(); $image->id_product = (int) $product->id; $image->position = Image::getHighestPosition($product->id) + 1; $image->cover = !$product_has_images ? true : false; $field_error = $image->validateFields(UNFRIENDLY_ERROR, true); $lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true); if ($field_error === true && $lang_field_error === true && $image->add()) { $image->associateTo($id_shop_list); if (!AdminImportController::copyImg($product->id, $image->id, $url, 'products', !Tools::getValue('regenerate'))) { $this->warnings[] = sprintf(Tools::displayError('Error copying image: %s'), $url); $image->delete(); } else { $id_image[] = (int) $image->id; } } else { $this->warnings[] = sprintf(Tools::displayError('%s cannot be saved'), isset($image->id_product) ? ' (' . $image->id_product . ')' : ''); $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . mysql_error(); } } } } elseif (isset($info['image_position']) && $info['image_position']) { $info['image_position'] = explode(',', $info['image_position']); if (is_array($info['image_position']) && count($info['image_position'])) { foreach ($info['image_position'] as $position) { // choose images from product by position $images = $product->getImages($default_language); if ($images) { foreach ($images as $row) { if ($row['position'] == (int) $position) { $id_image[] = (int) $row['id_image']; break; } } } if (empty($id_image)) { $this->warnings[] = sprintf(Tools::displayError('No image was found for combination with id_product = %s and image position = %s.'), $product->id, (int) $position); } } } } $id_attribute_group = 0; // groups $groups_attributes = array(); if (isset($info['group'])) { foreach (explode($this->multiple_value_separator, $info['group']) as $key => $group) { if (empty($group)) { continue; } $tab_group = explode(':', $group); $group = trim($tab_group[0]); if (!isset($tab_group[1])) { $type = 'select'; } else { $type = trim($tab_group[1]); } // sets group $groups_attributes[$key]['group'] = $group; // if position is filled if (isset($tab_group[2])) { $position = trim($tab_group[2]); } else { $position = false; } if (!isset($groups[$group])) { $obj = new AttributeGroup(); $obj->is_color_group = false; $obj->group_type = pSQL($type); $obj->name[$default_language] = $group; $obj->public_name[$default_language] = $group; $obj->position = !$position ? AttributeGroup::getHigherPosition() + 1 : $position; if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { $obj->add(); $obj->associateTo($id_shop_list); $groups[$group] = $obj->id; } else { $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''); } // fills groups attributes $id_attribute_group = $obj->id; $groups_attributes[$key]['id'] = $id_attribute_group; } else { $id_attribute_group = $groups[$group]; $groups_attributes[$key]['id'] = $id_attribute_group; } } } // inits attribute $id_product_attribute = 0; $id_product_attribute_update = false; $attributes_to_add = array(); // for each attribute if (isset($info['attribute'])) { foreach (explode($this->multiple_value_separator, $info['attribute']) as $key => $attribute) { if (empty($attribute)) { continue; } $tab_attribute = explode(':', $attribute); $attribute = trim($tab_attribute[0]); // if position is filled if (isset($tab_attribute[1])) { $position = trim($tab_attribute[1]); } else { $position = false; } if (isset($groups_attributes[$key])) { $group = $groups_attributes[$key]['group']; if (!isset($attributes[$group . '_' . $attribute]) && count($groups_attributes[$key]) == 2) { $id_attribute_group = $groups_attributes[$key]['id']; $obj = new Attribute(); // sets the proper id (corresponding to the right key) $obj->id_attribute_group = $groups_attributes[$key]['id']; $obj->name[$default_language] = str_replace('\\n', '', str_replace('\\r', '', $attribute)); $obj->position = !$position && isset($groups[$group]) ? Attribute::getHigherPosition($groups[$group]) + 1 : $position; if (($field_error = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { $obj->add(); $obj->associateTo($id_shop_list); $attributes[$group . '_' . $attribute] = $obj->id; } else { $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : ''); } } $info['minimal_quantity'] = isset($info['minimal_quantity']) && $info['minimal_quantity'] ? (int) $info['minimal_quantity'] : 1; $info['wholesale_price'] = str_replace(',', '.', $info['wholesale_price']); $info['price'] = str_replace(',', '.', $info['price']); $info['ecotax'] = str_replace(',', '.', $info['ecotax']); $info['weight'] = str_replace(',', '.', $info['weight']); $info['available_date'] = Validate::isDate($info['available_date']) ? $info['available_date'] : null; if (!Validate::isEan13($info['ean13'])) { $this->warnings[] = sprintf(Tools::displayError('EAN13 "%1s" has incorrect value for product with id %2d.'), $info['ean13'], $product->id); $info['ean13'] = ''; } if ($info['default_on']) { $product->deleteDefaultAttributes(); } // if a reference is specified for this product, get the associate id_product_attribute to UPDATE if (isset($info['reference']) && !empty($info['reference'])) { $id_product_attribute = Combination::getIdByReference($product->id, strval($info['reference'])); // updates the attribute if ($id_product_attribute) { // gets all the combinations of this product $attribute_combinations = $product->getAttributeCombinations($default_language); foreach ($attribute_combinations as $attribute_combination) { if ($id_product_attribute && in_array($id_product_attribute, $attribute_combination)) { $product->updateAttribute($id_product_attribute, (double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, Configuration::get('PS_USE_ECOTAX') ? (double) $info['ecotax'] : 0, $id_image, strval($info['reference']), strval($info['ean13']), (int) $info['default_on'], 0, strval($info['upc']), (int) $info['minimal_quantity'], $info['available_date'], null, $id_shop_list); $id_product_attribute_update = true; if (isset($info['supplier_reference']) && !empty($info['supplier_reference'])) { $product->addSupplierReference($product->id_supplier, $id_product_attribute, $info['supplier_reference']); } } } } } // if no attribute reference is specified, creates a new one if (!$id_product_attribute) { $id_product_attribute = $product->addCombinationEntity((double) $info['wholesale_price'], (double) $info['price'], (double) $info['weight'], 0, Configuration::get('PS_USE_ECOTAX') ? (double) $info['ecotax'] : 0, (int) $info['quantity'], $id_image, strval($info['reference']), 0, strval($info['ean13']), (int) $info['default_on'], 0, strval($info['upc']), (int) $info['minimal_quantity'], $id_shop_list, $info['available_date']); if (isset($info['supplier_reference']) && !empty($info['supplier_reference'])) { $product->addSupplierReference($product->id_supplier, $id_product_attribute, $info['supplier_reference']); } } // fills our attributes array, in order to add the attributes to the product_attribute afterwards if (isset($attributes[$group . '_' . $attribute])) { $attributes_to_add[] = (int) $attributes[$group . '_' . $attribute]; } // after insertion, we clean attribute position and group attribute position $obj = new Attribute(); $obj->cleanPositions((int) $id_attribute_group, false); AttributeGroup::cleanPositions(); } } } $product->checkDefaultAttributes(); if (!$product->cache_default_attribute) { Product::updateDefaultAttribute($product->id); } if ($id_product_attribute) { // now adds the attributes in the attribute_combination table if ($id_product_attribute_update) { Db::getInstance()->execute(' DELETE FROM ' . _DB_PREFIX_ . 'product_attribute_combination WHERE id_product_attribute = ' . (int) $id_product_attribute); } foreach ($attributes_to_add as $attribute_to_add) { Db::getInstance()->execute(' INSERT IGNORE INTO ' . _DB_PREFIX_ . 'product_attribute_combination (id_attribute, id_product_attribute) VALUES (' . (int) $attribute_to_add . ',' . (int) $id_product_attribute . ')'); } // set advanced stock managment if (isset($info['advanced_stock_management'])) { if ($info['advanced_stock_management'] != 1 && $info['advanced_stock_management'] != 0) { $this->warnings[] = sprintf(Tools::displayError('Advanced stock management has incorrect value. Not set for product with id %d.'), $product->id); } elseif (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $info['advanced_stock_management'] == 1) { $this->warnings[] = sprintf(Tools::displayError('Advanced stock management is not enabled, cannot enable on product with id %d.'), $product->id); } else { $product->setAdvancedStockManagement($info['advanced_stock_management']); } // automaticly disable depends on stock, if a_s_m set to disabled if (StockAvailable::dependsOnStock($product->id) == 1 && $info['advanced_stock_management'] == 0) { StockAvailable::setProductDependsOnStock($product->id, 0, null, $id_product_attribute); } } // Check if warehouse exists if (isset($info['warehouse']) && $info['warehouse']) { if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { $this->warnings[] = sprintf(Tools::displayError('Advanced stock management is not enabled, warehouse is not set on product with id %d.'), $product->id); } else { if (Warehouse::exists($info['warehouse'])) { $warehouse_location_entity = new WarehouseProductLocation(); $warehouse_location_entity->id_product = $product->id; $warehouse_location_entity->id_product_attribute = $id_product_attribute; $warehouse_location_entity->id_warehouse = $info['warehouse']; if (WarehouseProductLocation::getProductLocation($product->id, $id_product_attribute, $info['warehouse']) !== false) { $warehouse_location_entity->update(); } else { $warehouse_location_entity->save(); } StockAvailable::synchronize($product->id); } else { $this->warnings[] = sprintf(Tools::displayError('Warehouse did not exist, cannot set on product %1$s.'), $product->name[$default_language_id]); } } } // stock available if (isset($info['depends_on_stock'])) { if ($info['depends_on_stock'] != 0 && $info['depends_on_stock'] != 1) { $this->warnings[] = sprintf(Tools::displayError('Incorrect value for depends on stock for product %1$s '), $product->name[$default_language_id]); } elseif ((!$info['advanced_stock_management'] || $info['advanced_stock_management'] == 0) && $info['depends_on_stock'] == 1) { $this->warnings[] = sprintf(Tools::displayError('Advanced stock management is not enabled, cannot set depends on stock %1$s '), $product->name[$default_language_id]); } else { StockAvailable::setProductDependsOnStock($product->id, $info['depends_on_stock'], null, $id_product_attribute); } // This code allows us to set qty and disable depends on stock if (isset($info['quantity']) && (int) $info['quantity']) { // if depends on stock and quantity, add quantity to stock if ($info['depends_on_stock'] == 1) { $stock_manager = StockManagerFactory::getManager(); $price = str_replace(',', '.', $info['wholesale_price']); if ($price == 0) { $price = 1.0E-6; } $price = round(floatval($price), 6); $warehouse = new Warehouse($info['warehouse']); if ($stock_manager->addProduct((int) $product->id, $id_product_attribute, $warehouse, (int) $info['quantity'], 1, $price, true)) { StockAvailable::synchronize((int) $product->id); } } else { if (Shop::isFeatureActive()) { foreach ($id_shop_list as $shop) { StockAvailable::setQuantity((int) $product->id, $id_product_attribute, (int) $info['quantity'], (int) $shop); } } else { StockAvailable::setQuantity((int) $product->id, $id_product_attribute, (int) $info['quantity'], $this->context->shop->id); } } } } else { if (Shop::isFeatureActive()) { foreach ($id_shop_list as $shop) { StockAvailable::setQuantity((int) $product->id, $id_product_attribute, (int) $info['quantity'], (int) $shop); } } else { StockAvailable::setQuantity((int) $product->id, $id_product_attribute, (int) $info['quantity'], $this->context->shop->id); } } } } $this->closeCsvFile($handle); }
public function attributeImport() { $defaultLanguage = Configuration::get('PS_LANG_DEFAULT'); $groups = array(); foreach (AttributeGroup::getAttributesGroups($defaultLanguage) as $group) { $groups[$group['name']] = (int) $group['id_attribute_group']; } $attributes = array(); foreach (Attribute::getAttributes($defaultLanguage) as $attribute) { $attributes[$attribute['attribute_group'] . '_' . $attribute['name']] = (int) $attribute['id_attribute']; } $this->receiveTab(); $handle = $this->openCsvFile(); $fsep = (is_null(Tools::getValue('multiple_value_separator')) or trim(Tools::getValue('multiple_value_separator')) == '') ? ',' : Tools::getValue('multiple_value_separator'); self::setLocale(); for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, Tools::getValue('separator')); $current_line++) { if (Tools::getValue('convert')) { $this->utf8_encode_array($line); } $info = self::getMaskedRow($line); $info = array_map('trim', $info); self::setDefaultValues($info); $product = new Product((int) $info['id_product'], false, $defaultLanguage); $id_product_attribute = $product->addProductAttribute((double) $info['price'], (double) $info['weight'], 0, (double) $info['ecotax'], (int) $info['quantity'], null, strval($info['reference']), strval($info['supplier_reference']), strval($info['ean13']), (int) $info['default_on'], strval($info['upc'])); foreach (explode($fsep, $info['options']) as $option) { list($group, $attribute) = array_map('trim', explode(':', $option)); if (!isset($groups[$group])) { $obj = new AttributeGroup(); $obj->is_color_group = false; $obj->name[$defaultLanguage] = $group; $obj->public_name[$defaultLanguage] = $group; if (($fieldError = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { $obj->add(); $groups[$group] = $obj->id; } else { $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : ''); } } if (!isset($attributes[$group . '_' . $attribute])) { $obj = new Attribute(); $obj->id_attribute_group = $groups[$group]; $obj->name[$defaultLanguage] = $attribute; if (($fieldError = $obj->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $obj->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true) { $obj->add(); $attributes[$group . '_' . $attribute] = $obj->id; } else { $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : ''); } } Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'product_attribute_combination (id_attribute, id_product_attribute) VALUES (' . (int) $attributes[$group . '_' . $attribute] . ',' . (int) $id_product_attribute . ')'); } } $this->closeCsvFile($handle); }
public function renderForm() { $back = Tools::safeOutput(Tools::getValue('back', '')); if (empty($back)) { $back = self::$currentIndex . '&token=' . $this->token; } $this->toolbar_btn['save-and-stay'] = array('href' => '#', 'desc' => $this->l('Save and Stay')); $current_object = $this->loadObject(true); // All the filter are prefilled with the correct information $customer_filter = ''; if (Validate::isUnsignedId($current_object->id_customer) && ($customer = new Customer($current_object->id_customer)) && Validate::isLoadedObject($customer)) { $customer_filter = $customer->firstname . ' ' . $customer->lastname . ' (' . $customer->email . ')'; } $gift_product_filter = ''; if (Validate::isUnsignedId($current_object->gift_product) && ($product = new Product($current_object->gift_product, false, $this->context->language->id)) && Validate::isLoadedObject($product)) { $gift_product_filter = !empty($product->reference) ? $product->reference : $product->name; } $reduction_product_filter = ''; if (Validate::isUnsignedId($current_object->reduction_product) && ($product = new Product($current_object->reduction_product, false, $this->context->language->id)) && Validate::isLoadedObject($product)) { $reduction_product_filter = !empty($product->reference) ? $product->reference : $product->name; } $product_rule_groups = $this->getProductRuleGroupsDisplay($current_object); $attribute_groups = AttributeGroup::getAttributesGroups($this->context->language->id); $currencies = Currency::getCurrencies(); $languages = Language::getLanguages(); $countries = $current_object->getAssociatedRestrictions('country', true, true); $groups = $current_object->getAssociatedRestrictions('group', false, true); $shops = $current_object->getAssociatedRestrictions('shop', false, false); $cart_rules = $current_object->getAssociatedRestrictions('cart_rule', false, true); $carriers = $current_object->getAssociatedRestrictions('carrier', true, false); foreach ($carriers as &$carriers2) { foreach ($carriers2 as &$carrier) { foreach ($carrier as $field => &$value) { if ($field == 'name' && $value == '0') { $value = Configuration::get('PS_SHOP_NAME'); } } } } $gift_product_select = ''; $gift_product_attribute_select = ''; if ((int) $current_object->gift_product) { $search_products = $this->searchProducts($gift_product_filter); foreach ($search_products['products'] as $product) { $gift_product_select .= ' <option value="' . $product['id_product'] . '" ' . ($product['id_product'] == $current_object->gift_product ? 'selected="selected"' : '') . '> ' . $product['name'] . (count($product['combinations']) == 0 ? ' - ' . $product['formatted_price'] : '') . ' </option>'; if (count($product['combinations'])) { $gift_product_attribute_select .= '<select class="id_product_attribute" id="ipa_' . $product['id_product'] . '" name="ipa_' . $product['id_product'] . '">'; foreach ($product['combinations'] as $combination) { $gift_product_attribute_select .= ' <option ' . ($combination['id_product_attribute'] == $current_object->gift_product_attribute ? 'selected="selected"' : '') . ' value="' . $combination['id_product_attribute'] . '"> ' . $combination['attributes'] . ' - ' . $combination['formatted_price'] . ' </option>'; } $gift_product_attribute_select .= '</select>'; } } } $product = new Product($current_object->gift_product); $this->context->smarty->assign(array('show_toolbar' => true, 'toolbar_btn' => $this->toolbar_btn, 'toolbar_scroll' => $this->toolbar_scroll, 'title' => array($this->l('Payment: '), $this->l('Cart Rules')), 'defaultDateFrom' => date('Y-m-d H:00:00'), 'defaultDateTo' => date('Y-m-d H:00:00', strtotime('+1 month')), 'customerFilter' => $customer_filter, 'giftProductFilter' => $gift_product_filter, 'gift_product_select' => $gift_product_select, 'gift_product_attribute_select' => $gift_product_attribute_select, 'reductionProductFilter' => $reduction_product_filter, 'defaultCurrency' => Configuration::get('PS_CURRENCY_DEFAULT'), 'id_lang_default' => Configuration::get('PS_LANG_DEFAULT'), 'languages' => $languages, 'currencies' => $currencies, 'countries' => $countries, 'carriers' => $carriers, 'groups' => $groups, 'shops' => $shops, 'cart_rules' => $cart_rules, 'product_rule_groups' => $product_rule_groups, 'product_rule_groups_counter' => count($product_rule_groups), 'attribute_groups' => $attribute_groups, 'currentIndex' => self::$currentIndex, 'currentToken' => $this->token, 'currentObject' => $current_object, 'currentTab' => $this, 'hasAttribute' => $product->hasAttributes())); $this->content .= $this->createTemplate('form.tpl')->fetch(); $this->addJqueryUI('ui.datepicker'); return parent::renderForm(); }
function hookTop($params) { global $cookie; global $smarty; /* GETTING ATTRIBUTES */ if (Configuration::get('ADVSEARCH_ATTRIBUTES') == 1) { $attributeGroups = AttributeGroup::getAttributesGroups(intval($cookie->id_lang)); if (!sizeof($attributeGroups) || $attributeGroups === false) { $text = ''; } else { $text = '<h2>' . $this->l('ATTRIBUTES') . '</h2>'; //.md5('TAGS').'<br>'.md5('categories'); foreach ($attributeGroups as $group) { $attributes = AttributeGroup::getAttributes(intval($cookie->id_lang), $group['id_attribute_group']); if (!sizeof($attributes) || $attributes === false) { continue; } $text = $text . '<div onclick="showAtrybuty(' . $group['id_attribute_group'] . ');" class="dialogOpcjeTitle">' . $group['public_name'] . '</div>'; $text .= '<div id="opcje_' . $group['id_attribute_group'] . '" style="display:none;" class="opcjeItem">'; $text .= '<table>'; foreach ($attributes as $attribute) { $text = $text . '<tr><td><input name="atrybut_opcja[]" value="' . $attribute['id_attribute'] . '" type="checkbox" class="dialoginput"></td><td> ' . trim($attribute['name']) . '</td></tr>'; } $text .= '</table></div>'; } } } else { $text = ''; } /* GETTING ATTRIBUTES */ /* GETTING CATEGORIES */ if (Configuration::get('ADVSEARCH_CATEGORIES') == 1) { $result = Category::getCategories(intval($cookie->id_lang), true, false); $resultParents = array(); $resultIds = array(); foreach ($result as $row) { ${$row}['name'] = Category::hideCategoryPosition($row['name']); $resultParents[$row['id_parent']][] = $row; $resultIds[$row['id_category']] = $row; } $blockCategTree = $this->getTree($resultParents, $resultIds); $cats = $this->showCats($blockCategTree['children'], 0); } else { $cats = ''; } /* GETTING CATEGORIES */ /* GETTING SUPPLIERS */ if (Configuration::get('ADVSEARCH_SUPPLIERS') == 1) { $sup_sel = Supplier::getSuppliers(false, intval($params['cookie']->id_lang), true); if (sizeof($sup_sel) > 0) { sort($sup_sel); $sup_show = 1; } else { $sup_show = 0; } if ($sup_show == 1) { $var = array(); foreach ($sup_sel as $sup) { //$sup['nb_products']=$this->CountSupPro($sup['id_supplier']); $var[] = $sup; } $sup_sel = $var; } $supl_display = '<h2>' . $this->l('SUPPLIERS') . '</h2>'; foreach ($sup_sel as $supply) { $supl_display .= '<div class="dialogOpcjeTitle"><input type="checkbox" value="' . $supply['id_supplier'] . '" name="supply[]"> ' . $supply['name'] . '</div>'; } } else { $supl_display = ''; } /* GETTING SUPPLIERS */ /* GETTING MANUFACTURER */ if (Configuration::get('ADVSEARCH_MANUFACTURERS') == 1) { $man_sel = Manufacturer::getManufacturers(true, intval($params['cookie']->id_lang), true); $man_display = '<h2>' . $this->l('MANUFACTURER') . '</h2>'; foreach ($man_sel as $manuf) { if ($manuf['nb_products'] > 0) { $man_display .= '<div class="dialogOpcjeTitle"><input type="checkbox" value="' . $manuf['id_manufacturer'] . '" name="manufacturer[]"> ' . $manuf['name'] . '</div>'; } } } else { $man_display = ''; } /* GETTING MANUFACTURER */ /* GETTING TAG CLOUDS */ if (Configuration::get('ADVSEARCH_TAGS') == 1) { $tag_sel = array(); $tag_sel = Tag::getMainTags(intval($params['cookie']->id_lang), 500); if (sizeof($tag_sel)) { sort($tag_sel); } else { $tag_show = 0; } $tagi = '<h2>' . $this->l('TAGS') . '</h2><div class="dialogOpcjeTitle">'; for ($i = 0; $i < sizeof($tag_sel); $i++) { $tagi .= '<p id="advSearchTags" onclick="parent.location.href=\'modules/yasearch/results.php?tag=' . urlencode($tag_sel[$i]['name']) . '\'"> ' . ucfirst($tag_sel[$i]['name']) . '</p>'; } $tagi .= '</div>'; } else { $tagi = ''; } /* GETTING TAG CLOUDS */ $smarty->assign('tagi', $tagi); $smarty->assign('text', $text); $smarty->assign('cats', $cats); $smarty->assign('sup_sel', $supl_display); $smarty->assign('man_sel', $man_display); $smarty->assign('ENT_QUOTES', ENT_QUOTES); $smarty->assign('base_url', _PS_BASE_URL_ . __PS_BASE_URI__); return $this->display(__FILE__, 'yasearch-header.tpl'); }