public function initContent() { parent::initContent(); $id = $_GET['id']; $id_lang = $this->context->language->id; $product = new Product((int) $id); $link = new Link(); $url = $link->getProductLink($product); $features = Db::getInstance()->ExecuteS(' SELECT fl.name feature_name, fvl.value feature_value FROM ' . _DB_PREFIX_ . 'feature_product fp LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang=' . $id_lang . ' ) LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang=' . $id_lang . ') WHERE fp.id_product=' . $id); // print_r($features); $images = Image::getImages((int) $id_lang, (int) $product->id); //Limitamos el numero de fotos a cuatro solamente while (count($images) > 3) { $var = array_pop($images); } $this->context->smarty->assign(array('product' => $product, 'lang' => $id_lang, 'image' => $images, 'dir' => Tools::getHttpHost(true) . __PS_BASE_URI__ . 'modules/pdfproduct', 'email' => Configuration::get('PS_SHOP_EMAIL'), 'url' => $url, 'address' => Configuration::get('ADDRESS_SHOP'), 'background' => Configuration::get('BACKGROUND'))); $html = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'pdfproduct/views/templates/front/custom_template_content.tpl'); $dompdf = new DOMPDF(); $dompdf->set_option('enable_remote', TRUE); $dompdf->load_html($html); $dompdf->set_paper('a4', 'portrait'); $dompdf->render(); $dompdf->stream('producto'); //$this->setTemplate('custom_template_content.tpl'); //file_put_contents($filename, $dompdf->output()); //$pdf = new PDF($product, 'CustomPdf', Context::getContext()->smarty); //$img_file = Tools::getHttpHost(true).__PS_BASE_URI__. '/modules/pdfproduct/views/images/background.jpg'; //$pdf->pdf_renderer->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0); //$pdf->render(); }
public function sendCampaign() { // get abandoned cart : $sql = "SELECT * FROM (\n\t\tSELECT\n\t\tCONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, c.id_customer, a.id_cart, a.date_upd,a.date_add,\n\t\t\t\tIF (IFNULL(o.id_order, 'Non ordered') = 'Non ordered', IF(TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', a.`date_add`)) > 86400, 'Abandoned cart', 'Non ordered'), o.id_order) id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest\n\t\tFROM `" . _DB_PREFIX_ . "cart` a \n\t\t\t\tJOIN `" . _DB_PREFIX_ . "customer` c ON (c.id_customer = a.id_customer)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "currency` cu ON (cu.id_currency = a.id_currency)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "carrier` ca ON (ca.id_carrier = a.id_carrier)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "orders` o ON (o.id_cart = a.id_cart)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', co.`date_add`)) < 1800)\n\t\t) AS toto WHERE id_order='Abandoned cart'"; $currency = Context::getContext()->currency->sign; $defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $abandoned_carts = Db::getInstance()->ExecuteS($sql); // get all available campaigns $sqlCampaigns = 'SELECT * FROM `' . _DB_PREFIX_ . 'campaign` WHERE active=1'; $allCampaigns = Db::getInstance()->ExecuteS($sqlCampaigns); // loop on all abandoned carts foreach ($abandoned_carts as $abncart) { // loop on all available campaigns foreach ($allCampaigns as $camp) { $cartIsOnCampaign = $this->checkIfCartIsOnCampaign($abncart['date_add'], $camp['execution_time_day'], $camp['execution_time_hour']); if ($cartIsOnCampaign) { $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $customer = new Customer($abncart['id_customer']); $cR = new CartRule($camp['id_voucher'], $id_lang); $cart = new Cart($abncart['id_cart']); $products = $cart->getProducts(); $campM = new Campaign($camp['id_campaign']); if (!empty($products)) { $cart_content = $campM->getCartContentHeader(); } else { $cart_content = ''; } foreach ($products as $prod) { $p = new Product($prod['id_product'], true, $id_lang); $price_no_tax = Product::getPriceStatic($p->id, false, null, 2, null, false, true, 1, false, null, $abncart['id_cart'], null, $null, true, true, null, false, false); $total_no_tax = $prod['cart_quantity'] * $price_no_tax; $images = Image::getImages((int) $id_lang, (int) $p->id); $link = new Link(); $cart_content .= '<tr > <td align="center" ><img src="' . $link->getImageLink($p->link_rewrite, $images[0]['id_image']) . '" width="80"/></td> <td align="center" ><a href="' . $link->getProductLink($p) . '"/>' . $p->name . '</a></td> <td align="center" >' . Tools::displayprice($price_no_tax) . '</td> <td align="center" >' . $prod['cart_quantity'] . '</td> <td align="center" >' . Tools::displayprice($total_no_tax) . '</td> </tr>'; } $tpl_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{coupon_name}' => $cR->name, '{coupon_code}' => $cR->code, '{cart_content}' => $cart_content, '{coupon_value}' => $camp['voucher_amount_type'] == 'percent' ? $cR->reduction_percent . '%' : $currency . $cR->reduction_amount, '{coupon_valid_to}' => date('d/m/Y', strtotime($cR->date_to)), '{campaign_name}' => $camp['name']); $path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/'; // send email to customer : Mail::Send($id_lang, $campM->getFileName(), $camp['name'], $tpl_vars, $customer->email, null, null, null, null, null, $path, false, Context::getContext()->shop->id); // Email to admin : Mail::Send($id_lang, $campM->getFileName(), Mail::l(sprintf('Email sent to %s %s for campaign %s', $customer->lastname, $customer->firstname, $camp['name'])), $tpl_vars, Configuration::get('PS_SHOP_EMAIL'), null, null, null, null, null, $path, false, Context::getContext()->shop->id); // echo 'ID ' . $abncart['id_cart']; } } } }
<?php //complete code listing for controllers/guest/gallery.php include_once "models/ImageModel.php"; $image = new Image("img"); $imageList = $image->getImages(); $galleryView = (include_once "views/gallery_view.php"); return $galleryView;
function getPictures($prod_id, $link_rewrite) { $link = $this->context->link; $cover = Image::getCover($prod_id); $cover_picture = $link->getImageLink($link_rewrite, $prod_id . '-' . $cover['id_image'], $this->image_type); $pictures = array($cover_picture); $images = Image::getImages($this->id_lang, $prod_id); foreach ($images as $image) { if ($image['id_image'] != $cover['id_image']) { $picture = $link->getImageLink($link_rewrite, $prod_id . '-' . $image['id_image'], $this->image_type); $pictures[] = $picture; } } return array_slice($pictures, 0, 10); }
public static function addProductImage($id_product, $url) { ${"GLOBALS"}["qrvdspdp"] = "url"; ${"GLOBALS"}["foqvrjtcb"] = "url"; $cvtrsrijbi = "url"; $drrdziladf = "url"; ${$cvtrsrijbi} = trim(${${"GLOBALS"}["qrvdspdp"]}); $woqkepntwhz = "id_product"; if (empty(${${"GLOBALS"}["ttqxfd"]})) { return false; } ${"GLOBALS"}["hocovvwcref"] = "product_has_images"; ${$drrdziladf} = str_replace(" ", "%20", ${${"GLOBALS"}["foqvrjtcb"]}); ${"GLOBALS"}["ghxtspka"] = "product_has_images"; ${${"GLOBALS"}["ghxtspka"]} = (bool) Image::getImages(Context::getContext()->language->id, (int) ${${"GLOBALS"}["szukprvdkbb"]}); ${${"GLOBALS"}["bdufskktff"]} = new Image(); $image->id_product = (int) ${$woqkepntwhz}; $image->position = Image::getHighestPosition(${${"GLOBALS"}["szukprvdkbb"]}) + 1; $image->cover = ${${"GLOBALS"}["hocovvwcref"]} ? false : true; if ($image->validateFields(false, true) === true && $image->validateFieldsLang(false, true) === true && $image->add()) { $whmneeyreo = "url"; $image->associateTo(array(1)); return AgileHelper::copyImg(${${"GLOBALS"}["szukprvdkbb"]}, $image->id, ${$whmneeyreo}, "products", !Tools::getValue("regenerate")); } return false; }
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(); }
<title><![CDATA[<?php echo Configuration::get('PS_SHOP_NAME'); ?> ]]></title> <url><?php echo _PS_BASE_URL_ . __PS_BASE_URI__ . 'img/logo.jpg'; ?> </url> <link><?php echo _PS_BASE_URL_ . __PS_BASE_URI__; ?> </link> </image> <?php foreach ($products as $product) { $image = Image::getImages(intval($cookie->id_lang), $product['id_product']); echo "\t\t<item>\n"; echo "\t\t\t<title><![CDATA[" . $product['name'] . " - " . html_entity_decode(Tools::displayPrice(Product::getPriceStatic($product['id_product']), $currency), ENT_COMPAT, 'UTF-8') . " ]]></title>\n"; echo "\t\t\t<description>"; $cdata = true; if (is_array($image) and sizeof($image)) { echo "<![CDATA[<img src='" . _PS_BASE_URL_ . __PS_BASE_URI__ . "img/p/" . $image[0]['id_product'] . "-" . $image[0]['id_image'] . "-small.jpg' title='" . str_replace('&', '', $product['name']) . "' alt='thumb' />"; $cdata = false; } if ($cdata) { echo "<![CDATA["; } echo $product['description_short'] . "]]></description>\n"; echo "\t\t\t<link><![CDATA[" . htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite(intval($product['id_category_default']), $cookie->id_lang))) . $affiliate . "]]></link>\n"; echo "\t\t</item>\n"; }
protected function attributeImportOne($info, $default_language, &$groups, &$attributes, $regenerate, $shop_is_feature_active, $validateOnly = false) { AdminImportController::setDefaultValues($info); if (!$shop_is_feature_active) { $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']) . '" ', false); if (isset($datas['id_product']) && $datas['id_product']) { $product = new Product((int) $datas['id_product'], false, $default_language); } } else { return; } $id_image = array(); if (isset($info['image_url']) && $info['image_url']) { $info['image_url'] = explode($this->multiple_value_separator, $info['image_url']); if (is_array($info['image_url']) && count($info['image_url'])) { foreach ($info['image_url'] as $key => $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; if (isset($info['image_alt'])) { $alt = self::split($info['image_alt']); if (isset($alt[$key]) && strlen($alt[$key]) > 0) { $alt = self::createMultiLangField($alt[$key]); $image->legend = $alt; } } $field_error = $image->validateFields(UNFRIENDLY_ERROR, true); $lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true); if ($field_error === true && $lang_field_error === true && !$validateOnly && $image->add()) { $image->associateTo($id_shop_list); // FIXME: 2s/image ! if (!AdminImportController::copyImg($product->id, $image->id, $url, 'products', !$regenerate)) { $this->warnings[] = sprintf($this->trans('Error copying image: %s', array(), 'Admin.Parameters.Notification'), $url); $image->delete(); } else { $id_image[] = (int) $image->id; } // until here } else { if (!$validateOnly) { $this->warnings[] = sprintf($this->trans('%s cannot be saved', array(), 'Admin.Parameters.Notification'), isset($image->id_product) ? ' (' . $image->id_product . ')' : ''); } if ($field_error !== true || $lang_field_error !== true) { $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($this->multiple_value_separator, $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($this->trans('No image was found for combination with id_product = %s and image position = %s.', array(), 'Admin.Parameters.Notification'), $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) { // here, cannot avoid attributeGroup insertion to avoid an error during validation step. //if (!$validateOnly) { $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 { // already exists $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) { if (!$validateOnly) { $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($this->trans('EAN13 "%1s" has incorrect value for product with id %2d.', array(), 'Admin.Parameters.Notification'), $info['ean13'], $product->id); $info['ean13'] = ''; } if ($info['default_on'] && !$validateOnly) { $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 && !$validateOnly) { // 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)) { // FIXME: ~3s/declinaison $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']); } // until here } } } } // if no attribute reference is specified, creates a new one if (!$id_product_attribute && !$validateOnly) { $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 if (!$validateOnly) { $obj = new Attribute(); $obj->cleanPositions((int) $id_attribute_group, false); AttributeGroup::cleanPositions(); } } } } $product->checkDefaultAttributes(); if (!$product->cache_default_attribute && !$validateOnly) { Product::updateDefaultAttribute($product->id); } if ($id_product_attribute) { if (!$validateOnly) { // 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 . ')', false); } } // set advanced stock managment if (isset($info['advanced_stock_management'])) { if ($info['advanced_stock_management'] != 1 && $info['advanced_stock_management'] != 0) { $this->warnings[] = sprintf($this->trans('Advanced stock management has incorrect value. Not set for product with id %d.', array(), 'Admin.Parameters.Notification'), $product->id); } elseif (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $info['advanced_stock_management'] == 1) { $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, cannot enable on product with id %d.', array(), 'Admin.Parameters.Notification'), $product->id); } elseif (!$validateOnly) { $product->setAdvancedStockManagement($info['advanced_stock_management']); } // automaticly disable depends on stock, if a_s_m set to disabled if (!$validateOnly && 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($this->trans('Advanced stock management is not enabled, warehouse is not set on product with id %d.', array(), 'Admin.Parameters.Notification'), $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 (!$validateOnly) { 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($this->trans('Warehouse did not exist, cannot set on product %1$s.', array(), 'Admin.Parameters.Notification'), $product->name[$default_language]); } } } // stock available if (isset($info['depends_on_stock'])) { if ($info['depends_on_stock'] != 0 && $info['depends_on_stock'] != 1) { $this->warnings[] = sprintf($this->trans('Incorrect value for "Depends on stock" for product %1$s ', array(), 'Admin.Notifications.Error'), $product->name[$default_language]); } elseif ((!$info['advanced_stock_management'] || $info['advanced_stock_management'] == 0) && $info['depends_on_stock'] == 1) { $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, cannot set "Depends on stock" for product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language]); } elseif (!$validateOnly) { 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 (!$validateOnly && $stock_manager->addProduct((int) $product->id, $id_product_attribute, $warehouse, (int) $info['quantity'], 1, $price, true)) { StockAvailable::synchronize((int) $product->id); } } elseif (!$validateOnly) { if ($shop_is_feature_active) { 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); } } } } elseif (!$validateOnly) { // if not depends_on_stock set, use normal qty if ($shop_is_feature_active) { 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); } } } }
} if (!(is_array($product->link_rewrite) && count($product->link_rewrite) && !empty($product->link_rewrite[$id_lang]))) { $res = array(); foreach (Language::getIDs(false) as $id_lang) { $res[$id_lang] = $link_rewrite; } $product->link_rewrite = $res; } if ($product->save()) { $id_image = array(); //delete existing images if "delete_existing_images" is set to 1 $multiple_value_separator = ($separator = Tools::substr(strval(trim(Tools::getValue('multiple_value_separator'))), 0, 1)) ? $separator : ','; if (isset($prd['images']) && $prd['images']) { $image_url = explode('/', $prd['images']); $url = _PS_IMG_MGT_DIR_ . end($image_url); $product_has_images = (bool) Image::getImages($id_lang, $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); $id_shop_list = array(); $errors = array(); $warnings = array(); $id_shop_list[] = $product->id_shop_default; if ($image->add()) { $image->associateTo($id_shop_list); $image->getPathForCreation(); $image_final = $image->getPathForCreation() . '.jpg'; if (Tools::copy($url, $image_final)) {
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 static function addProductImage($id_product, $url) { $seqtjskmdfi = "url"; ${${"GLOBALS"}["uhoixbgwu"]} = trim(${$seqtjskmdfi}); if (empty(${${"GLOBALS"}["uhoixbgwu"]})) { return false; } $lnmoeujjg = "id_product"; $uplftstbult = "image"; ${"GLOBALS"}["mrbbkxa"] = "url"; ${${"GLOBALS"}["mrbbkxa"]} = str_replace(" ", "%20", ${${"GLOBALS"}["uhoixbgwu"]}); ${${"GLOBALS"}["btjrhesgdily"]} = (bool) Image::getImages(Context::getContext()->language->id, (int) ${$lnmoeujjg}); ${$uplftstbult} = new Image(); $image->id_product = (int) ${${"GLOBALS"}["hmkfzguifam"]}; $image->position = Image::getHighestPosition(${${"GLOBALS"}["hmkfzguifam"]}) + 1; $image->cover = ${${"GLOBALS"}["btjrhesgdily"]} ? false : true; if ($image->validateFields(false, true) === true && $image->validateFieldsLang(false, true) === true && $image->add()) { ${"GLOBALS"}["cubrmeyruje"] = "id_product"; $image->associateTo(array(1)); return AgileHelper::copyImg(${${"GLOBALS"}["cubrmeyruje"]}, $image->id, ${${"GLOBALS"}["uhoixbgwu"]}, "products", !Tools::getValue("regenerate")); } return false; }
public function hookHeader($params) { $shop_id = $this->getShopId(); $buttons_code = $this->client->getButtonsCode(); if (Configuration::get('ADDSHOPPERS_OPENGRAPH') == '1') { $this->context->smarty->assign('buttons_opengraph', $buttons_code['buttons']['open-graph']); } if (Configuration::get('ADDSHOPPERS_BUTTONS') == '1') { $this->context->smarty->assign('buttons_social', $buttons_code['buttons']['button2']); } $id_lang = (int) Tools::getValue('id_lang', (int) Configuration::get('PS_LANG_DEFAULT')); $this->context->smarty->assign(array('shop_id' => Tools::safeOutput($shop_id), 'default_account' => $shop_id == $this->client->getDefaultShopId(), 'social' => Tools::safeOutput(Configuration::get('ADDSHOPPERS_BUTTONS')), 'opengraph' => Tools::safeOutput(Configuration::get('ADDSHOPPERS_OPENGRAPH')), 'actual_url' => Tools::safeOutput($this->_getCurrentUrl()), 'absolute_base_url' => Tools::safeOutput($this->_getAbsoluteBaseUrl()), 'id_lang' => (int) $id_lang)); if (Tools::isSubmit('id_product')) { $product = new Product((int) Tools::getValue('id_product')); if (Validate::isLoadedObject($product)) { $currency = new Currency((int) $this->context->cookie->id_currency); $this->context->smarty->assign(array('id_product' => (int) $product->id, 'stock' => isset($product->available_now) ? Tools::safeOutput(AddshoppersClient::WIDGET_STOCK_IN_STOCK) : Tools::safeOutput(AddshoppersClient::WIDGET_STOCK_OUT_OF_STOCK), 'price' => Tools::safeOutput($currency->sign) . number_format((double) $product->getPrice(), 2), 'product_name' => Tools::safeOutput($product->name[$id_lang]), 'product_description' => Tools::safeOutput($product->description[$id_lang]), 'is_product_page' => true)); $quantity = (int) StockAvailable::getQuantityAvailableByProduct((int) $product->id); if ($quantity > 0) { $this->context->smarty->assign('instock', (int) $quantity); } $images = Image::getImages((int) $id_lang, (int) $product->id); if (is_array($images) && isset($images[0])) { $this->context->smarty->assign('id_image', (int) $images[0]['id_image']); } } else { $this->context->smarty->assign('is_product_page', false); } } else { $this->context->smarty->assign('is_product_page', false); } return $this->display(__FILE__, 'header.tpl'); }
function content_55576e4d495d27_71185436($_smarty_tpl) { ?> <div <?php if (isset($_smarty_tpl->tpl_vars['id']->value) && $_smarty_tpl->tpl_vars['id']->value) { ?> id="<?php echo $_smarty_tpl->tpl_vars['id']->value; ?> "<?php } ?> class="carousel-list clearfix<?php if (isset($_smarty_tpl->tpl_vars['c_class']->value) && $_smarty_tpl->tpl_vars['c_class']->value) { ?> <?php echo $_smarty_tpl->tpl_vars['c_class']->value; } ?> owl_wrap"> <?php if (isset($_smarty_tpl->tpl_vars['products']->value) && $_smarty_tpl->tpl_vars['products']->value && count($_smarty_tpl->tpl_vars['products']->value) > 0) { ?> <!-- Products list --> <?php $_smarty_tpl->tpl_vars['product'] = new Smarty_Variable(); $_smarty_tpl->tpl_vars['product']->_loop = false; $_from = $_smarty_tpl->tpl_vars['products']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars['product']->key => $_smarty_tpl->tpl_vars['product']->value) { $_smarty_tpl->tpl_vars['product']->_loop = true; ?> <ul class="product_list grid"> <li class="ajax_block_product item"> <?php $_smarty_tpl->tpl_vars['imginfo'] = new Smarty_variable(Image::getImages(Language::getIdByIso($_smarty_tpl->tpl_vars['lang_iso']->value), $_smarty_tpl->tpl_vars['product']->value['id_product']), null, 0); ?> <?php $_smarty_tpl->tpl_vars['new_idimg'] = new Smarty_variable('', null, 0); ?> <?php $_smarty_tpl->tpl_vars['imgitem'] = new Smarty_Variable(); $_smarty_tpl->tpl_vars['imgitem']->_loop = false; $_from = $_smarty_tpl->tpl_vars['imginfo']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars['imgitem']->key => $_smarty_tpl->tpl_vars['imgitem']->value) { $_smarty_tpl->tpl_vars['imgitem']->_loop = true; ?> <?php if (!$_smarty_tpl->tpl_vars['imgitem']->value['cover']) { ?> <?php $_smarty_tpl->tpl_vars['new_idimg'] = new Smarty_variable((string) $_smarty_tpl->tpl_vars['imgitem']->value['id_product'] . "-" . (string) $_smarty_tpl->tpl_vars['imgitem']->value['id_image'], null, 0); ?> <?php break 1; ?> <?php } ?> <?php } ?> <div class="product-container" itemscope itemtype="http://schema.org/Product"> <div class="left-block"> <div class="product-image-container"> <a class="product_img_link" href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> " title="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); ?> " itemprop="url"> <img class="replace-2x img-responsive" src="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value['link_rewrite'], $_smarty_tpl->tpl_vars['product']->value['id_image'], 'home_default'), ENT_QUOTES, 'UTF-8', true); ?> " alt="<?php if (!empty($_smarty_tpl->tpl_vars['product']->value['legend'])) { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['legend'], ENT_QUOTES, 'UTF-8', true); } else { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); } ?> " title="<?php if (!empty($_smarty_tpl->tpl_vars['product']->value['legend'])) { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['legend'], ENT_QUOTES, 'UTF-8', true); } else { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); } ?> " <?php if (isset($_smarty_tpl->tpl_vars['homeSize']->value)) { ?> width="<?php echo $_smarty_tpl->tpl_vars['homeSize']->value['width']; ?> " height="<?php echo $_smarty_tpl->tpl_vars['homeSize']->value['height']; ?> "<?php } ?> itemprop="image" /> </a> <?php if (!$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value && (isset($_smarty_tpl->tpl_vars['product']->value['show_price']) && $_smarty_tpl->tpl_vars['product']->value['show_price'] || isset($_smarty_tpl->tpl_vars['product']->value['available_for_order']) && $_smarty_tpl->tpl_vars['product']->value['available_for_order'])) { ?> <div class="content_price" itemprop="offers" itemscope itemtype="http://schema.org/Offer"> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['show_price']) && $_smarty_tpl->tpl_vars['product']->value['show_price'] && !isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value)) { ?> <span class="old-price product-price"> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['displayWtPrice'][0][0]->displayWtPrice(array('p' => $_smarty_tpl->tpl_vars['product']->value['price_without_reduction']), $_smarty_tpl); ?> </span> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['specific_prices']) && $_smarty_tpl->tpl_vars['product']->value['specific_prices'] && isset($_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction']) && $_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction'] > 0) { ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "old_price"), $_smarty_tpl); ?> <?php if ($_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction_type'] == 'percentage') { ?> <span class="price-percent-reduction"><?php echo $_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction'] * 100; ?> %<span><?php echo smartyTranslate(array('s' => 'OFF'), $_smarty_tpl); ?> </span></span> <?php } ?> <?php } ?> <span itemprop="price" class="price product-price"> <?php if (!$_smarty_tpl->tpl_vars['priceDisplay']->value) { echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['product']->value['price']), $_smarty_tpl); } else { echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['product']->value['price_tax_exc']), $_smarty_tpl); } ?> </span> <meta itemprop="priceCurrency" content="<?php echo $_smarty_tpl->tpl_vars['currency']->value->iso_code; ?> " /> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "price"), $_smarty_tpl); ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "unit_price"), $_smarty_tpl); ?> <?php } ?> </div> <?php } ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['new']) && $_smarty_tpl->tpl_vars['product']->value['new'] == 1) { ?> <a class="new-box" href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> "> <span class="new-label"><?php echo smartyTranslate(array('s' => 'New'), $_smarty_tpl); ?> </span> </a> <?php } ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['on_sale']) && $_smarty_tpl->tpl_vars['product']->value['on_sale'] && isset($_smarty_tpl->tpl_vars['product']->value['show_price']) && $_smarty_tpl->tpl_vars['product']->value['show_price'] && !$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) { ?> <a class="sale-box<?php if (isset($_smarty_tpl->tpl_vars['product']->value['new']) && !$_smarty_tpl->tpl_vars['product']->value['new']) { ?> no-new<?php } ?> " href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> "> <span class="sale-label"><?php echo smartyTranslate(array('s' => 'Sale!'), $_smarty_tpl); ?> </span> </a> <?php } ?> <div class="functional-buttons clearfix"> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => 'displayProductListFunctionalButtons', 'product' => $_smarty_tpl->tpl_vars['product']->value), $_smarty_tpl); ?> <?php if (isset($_smarty_tpl->tpl_vars['comparator_max_item']->value) && $_smarty_tpl->tpl_vars['comparator_max_item']->value) { ?> <div class="compare"> <a class="add_to_compare" title="<?php echo smartyTranslate(array('s' => "Add to compare"), $_smarty_tpl); ?> " href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> " data-id-product="<?php echo $_smarty_tpl->tpl_vars['product']->value['id_product']; ?> "><i class="fa-compress"></i></a> </div> <?php } ?> <?php if (isset($_smarty_tpl->tpl_vars['quick_view']->value) && $_smarty_tpl->tpl_vars['quick_view']->value) { ?> <a class="quick-view" href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> " rel="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> "> <i class="fa fa-search"></i> </a> <?php } ?> <?php if (($_smarty_tpl->tpl_vars['product']->value['id_product_attribute'] == 0 || isset($_smarty_tpl->tpl_vars['add_prod_display']->value) && $_smarty_tpl->tpl_vars['add_prod_display']->value == 1) && $_smarty_tpl->tpl_vars['product']->value['available_for_order'] && !isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value) && $_smarty_tpl->tpl_vars['product']->value['minimal_quantity'] <= 1 && $_smarty_tpl->tpl_vars['product']->value['customizable'] != 2 && !$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) { ?> <?php if ((!isset($_smarty_tpl->tpl_vars['product']->value['customization_required']) || !$_smarty_tpl->tpl_vars['product']->value['customization_required']) && ($_smarty_tpl->tpl_vars['product']->value['allow_oosp'] || $_smarty_tpl->tpl_vars['product']->value['quantity'] > 0)) { ?> <?php if (isset($_smarty_tpl->tpl_vars['static_token']->value)) { ?> <a class="button ajax_add_to_cart_button btn btn-default" href="<?php ob_start(); echo intval($_smarty_tpl->tpl_vars['product']->value['id_product']); $_tmp1 = ob_get_clean(); echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getPageLink('cart', false, null, "add=1&id_product=" . $_tmp1 . "&token=" . (string) $_smarty_tpl->tpl_vars['static_token']->value, false), ENT_QUOTES, 'UTF-8', true); ?> " rel="nofollow" title="<?php echo smartyTranslate(array('s' => 'Add to cart'), $_smarty_tpl); ?> " data-id-product="<?php echo intval($_smarty_tpl->tpl_vars['product']->value['id_product']); ?> "> <span><?php echo smartyTranslate(array('s' => 'Add to cart'), $_smarty_tpl); ?> </span> </a> <?php } else { ?> <a class="button ajax_add_to_cart_button btn btn-default" href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getPageLink('cart', false, null, 'add=1&id_product={$product.id_product|intval}', false), ENT_QUOTES, 'UTF-8', true); ?> " rel="nofollow" title="<?php echo smartyTranslate(array('s' => 'Add to cart'), $_smarty_tpl); ?> " data-id-product="<?php echo intval($_smarty_tpl->tpl_vars['product']->value['id_product']); ?> "> <span><?php echo smartyTranslate(array('s' => 'Add to cart'), $_smarty_tpl); ?> </span> </a> <?php } ?> <?php } else { ?> <span class="button ajax_add_to_cart_button btn btn-default disabled"> <span><?php echo smartyTranslate(array('s' => 'Add to cart'), $_smarty_tpl); ?> </span> </span> <?php } ?> <?php } ?> </div> </div> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductDeliveryTime", 'product' => $_smarty_tpl->tpl_vars['product']->value), $_smarty_tpl); ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "weight"), $_smarty_tpl); ?> </div> <div class="right-block"> <h5 itemprop="name"> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['pack_quantity']) && $_smarty_tpl->tpl_vars['product']->value['pack_quantity']) { echo intval($_smarty_tpl->tpl_vars['product']->value['pack_quantity']) . ' x '; } ?> <a class="product-name" href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> " title="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); ?> " itemprop="url" > <?php echo htmlspecialchars($_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['truncate'][0][0]->smarty_modifier_truncate($_smarty_tpl->tpl_vars['product']->value['name'], 32, ''), ENT_QUOTES, 'UTF-8', true); ?> </a> </h5> <p class="product-desc" itemprop="description"> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['truncate'][0][0]->smarty_modifier_truncate(strip_tags($_smarty_tpl->tpl_vars['product']->value['description_short']), 36, ''); ?> </p> <p class="product-desc-list" itemprop="description"> <?php echo strip_tags($_smarty_tpl->tpl_vars['product']->value['description_short']); ?> </p> <?php if (!$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value && (isset($_smarty_tpl->tpl_vars['product']->value['show_price']) && $_smarty_tpl->tpl_vars['product']->value['show_price'] || isset($_smarty_tpl->tpl_vars['product']->value['available_for_order']) && $_smarty_tpl->tpl_vars['product']->value['available_for_order'])) { ?> <div itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="content_price"> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['show_price']) && $_smarty_tpl->tpl_vars['product']->value['show_price'] && !isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value)) { ?> <meta itemprop="priceCurrency" content="<?php echo $_smarty_tpl->tpl_vars['currency']->value->iso_code; ?> " /> <span itemprop="price" class="price product-price"> <?php if (!$_smarty_tpl->tpl_vars['priceDisplay']->value) { echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['product']->value['price']), $_smarty_tpl); } else { echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['product']->value['price_tax_exc']), $_smarty_tpl); } ?> </span> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['specific_prices']) && $_smarty_tpl->tpl_vars['product']->value['specific_prices'] && isset($_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction']) && $_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction'] > 0) { ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "old_price"), $_smarty_tpl); ?> <span class="old-price product-price"> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['displayWtPrice'][0][0]->displayWtPrice(array('p' => $_smarty_tpl->tpl_vars['product']->value['price_without_reduction']), $_smarty_tpl); ?> </span> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'id_product' => $_smarty_tpl->tpl_vars['product']->value['id_product'], 'type' => "old_price"), $_smarty_tpl); ?> <?php if ($_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction_type'] == 'percentage') { ?> <span class="price-percent-reduction"><?php echo $_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction'] * 100; ?> %<span><?php echo smartyTranslate(array('s' => 'OFF'), $_smarty_tpl); ?> </span></span> <?php } ?> <?php } ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "price"), $_smarty_tpl); ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "unit_price"), $_smarty_tpl); ?> <?php } ?> </div> <?php } ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => 'displayProductListReviews', 'product' => $_smarty_tpl->tpl_vars['product']->value), $_smarty_tpl); ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['color_list'])) { ?> <div class="color-list-container"><?php echo $_smarty_tpl->tpl_vars['product']->value['color_list']; ?> </div> <?php } ?> <div class="product-flags"> <?php if (!$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value && (isset($_smarty_tpl->tpl_vars['product']->value['show_price']) && $_smarty_tpl->tpl_vars['product']->value['show_price'] || isset($_smarty_tpl->tpl_vars['product']->value['available_for_order']) && $_smarty_tpl->tpl_vars['product']->value['available_for_order'])) { ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['online_only']) && $_smarty_tpl->tpl_vars['product']->value['online_only']) { ?> <span class="online_only"><?php echo smartyTranslate(array('s' => 'Online only'), $_smarty_tpl); ?> </span> <?php } ?> <?php } ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['on_sale']) && $_smarty_tpl->tpl_vars['product']->value['on_sale'] && isset($_smarty_tpl->tpl_vars['product']->value['show_price']) && $_smarty_tpl->tpl_vars['product']->value['show_price'] && !$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) { ?> <?php } elseif (isset($_smarty_tpl->tpl_vars['product']->value['reduction']) && $_smarty_tpl->tpl_vars['product']->value['reduction'] && isset($_smarty_tpl->tpl_vars['product']->value['show_price']) && $_smarty_tpl->tpl_vars['product']->value['show_price'] && !$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) { ?> <span class="discount"><?php echo smartyTranslate(array('s' => 'Reduced price!'), $_smarty_tpl); ?> </span> <?php } ?> </div> <?php if (!empty($_smarty_tpl->tpl_vars['product']->value['reference'])) { ?> <span class="itemcode"><?php echo smartyTranslate(array('s' => 'Item Code: '), $_smarty_tpl); ?> <span class="itemcode-value"><?php echo $_smarty_tpl->tpl_vars['product']->value['reference']; ?> </span></span> <?php } ?> <?php if (!$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value && $_smarty_tpl->tpl_vars['PS_STOCK_MANAGEMENT']->value && (isset($_smarty_tpl->tpl_vars['product']->value['show_price']) && $_smarty_tpl->tpl_vars['product']->value['show_price'] || isset($_smarty_tpl->tpl_vars['product']->value['available_for_order']) && $_smarty_tpl->tpl_vars['product']->value['available_for_order'])) { ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['available_for_order']) && $_smarty_tpl->tpl_vars['product']->value['available_for_order'] && !isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value)) { ?> <span itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="availability"> <span class="availability-text"><?php echo smartyTranslate(array('s' => 'Availability:'), $_smarty_tpl); ?> </span> <?php if ($_smarty_tpl->tpl_vars['product']->value['allow_oosp'] || $_smarty_tpl->tpl_vars['product']->value['quantity'] > 0) { ?> <span class="<?php if ($_smarty_tpl->tpl_vars['product']->value['quantity'] <= 0 && !$_smarty_tpl->tpl_vars['product']->value['allow_oosp']) { ?> out-of-stock<?php } else { ?> available-now<?php } ?> "> <link itemprop="availability" href="http://schema.org/InStock" /><?php if ($_smarty_tpl->tpl_vars['product']->value['quantity'] <= 0) { if ($_smarty_tpl->tpl_vars['product']->value['allow_oosp']) { if (isset($_smarty_tpl->tpl_vars['product']->value['available_later']) && $_smarty_tpl->tpl_vars['product']->value['available_later']) { echo $_smarty_tpl->tpl_vars['product']->value['available_later']; } else { echo smartyTranslate(array('s' => 'In Stock'), $_smarty_tpl); } } else { echo smartyTranslate(array('s' => 'Out of stock'), $_smarty_tpl); } } else { if (isset($_smarty_tpl->tpl_vars['product']->value['available_now']) && $_smarty_tpl->tpl_vars['product']->value['available_now']) { echo $_smarty_tpl->tpl_vars['product']->value['available_now']; } else { echo smartyTranslate(array('s' => 'In Stock'), $_smarty_tpl); } } ?> </span> <?php } elseif (isset($_smarty_tpl->tpl_vars['product']->value['quantity_all_versions']) && $_smarty_tpl->tpl_vars['product']->value['quantity_all_versions'] > 0) { ?> <span class="available-dif"> <link itemprop="availability" href="http://schema.org/LimitedAvailability" /><?php echo smartyTranslate(array('s' => 'Product available with different options'), $_smarty_tpl); ?> </span> <?php } else { ?> <span class="out-of-stock"> <link itemprop="availability" href="http://schema.org/OutOfStock" /><?php echo smartyTranslate(array('s' => 'Out stock'), $_smarty_tpl); ?> </span> <?php } ?> </span> <?php } ?> <?php } ?> </div> </div><!-- .product-container> --> </li> </ul> <?php } $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'min_item')); $_block_repeat = true; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'min_item'), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); echo smartyTranslate(array('s' => 'Please select at least one product', 'js' => 1), $_smarty_tpl); $_block_content = ob_get_clean(); $_block_repeat = false; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'min_item'), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> <?php $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'max_item')); $_block_repeat = true; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'max_item'), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); echo smartyTranslate(array('s' => 'You cannot add more than %d product(s) to the product comparison', 'sprintf' => $_smarty_tpl->tpl_vars['comparator_max_item']->value, 'js' => 1), $_smarty_tpl); $_block_content = ob_get_clean(); $_block_repeat = false; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'max_item'), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('comparator_max_item' => $_smarty_tpl->tpl_vars['comparator_max_item']->value), $_smarty_tpl); ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('comparedProductsIds' => $_smarty_tpl->tpl_vars['compared_products']->value), $_smarty_tpl); ?> <?php } ?> </div><?php }
public static function addProductImage($id_product, $url) { $rhueeqpyqid = "url"; $hrqreqrws = "product_has_images"; $gdvfsxvvwqw = "id_product"; $muucuokjnr = "url"; ${$muucuokjnr} = trim(${$rhueeqpyqid}); ${"GLOBALS"}["spvdeam"] = "url"; if (empty(${${"GLOBALS"}["csdyhfby"]})) { return false; } ${${"GLOBALS"}["csdyhfby"]} = str_replace(" ", "%20", ${${"GLOBALS"}["spvdeam"]}); ${"GLOBALS"}["mmicugw"] = "image"; ${$hrqreqrws} = (bool) Image::getImages(Context::getContext()->language->id, (int) ${$gdvfsxvvwqw}); ${${"GLOBALS"}["mmicugw"]} = new Image(); $image->id_product = (int) ${${"GLOBALS"}["ktxxdlcenjrd"]}; $image->position = Image::getHighestPosition(${${"GLOBALS"}["ktxxdlcenjrd"]}) + 1; ${"GLOBALS"}["mincqrvbtcit"] = "product_has_images"; $image->cover = ${${"GLOBALS"}["mincqrvbtcit"]} ? false : true; if ($image->validateFields(false, true) === true && $image->validateFieldsLang(false, true) === true && $image->add()) { $image->associateTo(array(1)); ${"GLOBALS"}["vgrilvvuoi"] = "id_product"; ${"GLOBALS"}["flxzymmafk"] = "url"; return AgileHelper::copyImg(${${"GLOBALS"}["vgrilvvuoi"]}, $image->id, ${${"GLOBALS"}["flxzymmafk"]}, "products", !Tools::getValue("regenerate")); } return false; }
/** * Display duplicate action link */ public function displayDuplicateLink($token = null, $id, $name = null) { $tpl = $this->createTemplate('list_action_duplicate.tpl'); if (!array_key_exists('Bad SQL query', self::$cache_lang)) { self::$cache_lang['Duplicate'] = $this->l('Duplicate', 'Helper'); } if (!array_key_exists('Copy images too?', self::$cache_lang)) { self::$cache_lang['Copy images too?'] = $this->l('This will copy the images too. If you wish to proceed, click "Yes". If not, click "No".', 'Helper'); } $duplicate = $this->currentIndex . '&' . $this->identifier . '=' . $id . '&duplicate' . $this->table; $confirm = self::$cache_lang['Copy images too?']; if ($this->table == 'product' && !(bool) Image::getImages($this->context->language->id, (int) $id)) { $confirm = ''; } $tpl->assign(array('href' => $this->currentIndex . '&' . $this->identifier . '=' . $id . '&view' . $this->table . '&token=' . ($token != null ? $token : $this->token), 'action' => self::$cache_lang['Duplicate'], 'confirm' => $confirm, 'location_ok' => $duplicate . '&token=' . ($token != null ? $token : $this->token), 'location_ko' => $duplicate . '&noimage=1&token=' . ($token ? $token : $this->token))); return $tpl->fetch(); }
public function productImport() { global $cookie; $this->receiveTab(); $handle = $this->openCsvFile(); $defaultLanguageId = (int) Configuration::get('PS_LANG_DEFAULT'); 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); if (array_key_exists('id', $info) and (int) $info['id'] and Product::existsInDatabase((int) $info['id'])) { $product = new Product((int) $info['id']); $categoryData = Product::getIndexedCategories((int) $product->id); foreach ($categoryData as $tmp) { $product->category[] = $tmp['id_category']; } } else { $product = new Product(); } self::setEntityDefaultValues($product); self::array_walk($info, array('AdminImport', 'fillInfo'), $product); $trg_id = (int) $product->id_tax_rules_group; if ($product->id_tax_rules_group == 0 || !Validate::isLoadedObject(new TaxRulesGroup($trg_id))) { $this->_addProductWarning('id_tax_rules_group', $product->id_tax_rules_group, Tools::displayError('Invalid tax rule group ID, you first need a group with this ID.')); } else { $product->tax_rate = TaxRulesGroup::getTaxesRate((int) $product->id_tax_rules_group, Configuration::get('PS_COUNTRY_DEFAULT'), 0, 0); } if (isset($product->manufacturer) and is_numeric($product->manufacturer) and Manufacturer::manufacturerExists((int) $product->manufacturer)) { $product->id_manufacturer = (int) $product->manufacturer; } elseif (isset($product->manufacturer) and is_string($product->manufacturer) and !empty($product->manufacturer)) { if ($manufacturer = Manufacturer::getIdByName($product->manufacturer)) { $product->id_manufacturer = (int) $manufacturer; } else { $manufacturer = new Manufacturer(); $manufacturer->name = $product->manufacturer; if (($fieldError = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $manufacturer->add()) { $product->id_manufacturer = (int) $manufacturer->id; } else { $this->_errors[] = $manufacturer->name . (isset($manufacturer->id) ? ' (' . $manufacturer->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } } if (isset($product->supplier) and is_numeric($product->supplier) and Supplier::supplierExists((int) $product->supplier)) { $product->id_supplier = (int) $product->supplier; } elseif (isset($product->supplier) and is_string($product->supplier) and !empty($product->supplier)) { if ($supplier = Supplier::getIdByName($product->supplier)) { $product->id_supplier = (int) $supplier; } else { $supplier = new Supplier(); $supplier->name = $product->supplier; if (($fieldError = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $supplier->add()) { $product->id_supplier = (int) $supplier->id; } else { $this->_errors[] = $supplier->name . (isset($supplier->id) ? ' (' . $supplier->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } } if (isset($product->price_tex) and !isset($product->price_tin)) { $product->price = $product->price_tex; } elseif (isset($product->price_tin) and !isset($product->price_tex)) { $product->price = $product->price_tin; // If a tax is already included in price, withdraw it from price if ($product->tax_rate) { $product->price = (double) number_format($product->price / (1 + $product->tax_rate / 100), 6); } } elseif (isset($product->price_tin) and isset($product->price_tex)) { $product->price = $product->price_tex; } if (isset($product->category) and is_array($product->category) and sizeof($product->category)) { $product->id_category = array(); // Reset default values array foreach ($product->category as $value) { if (is_numeric($value)) { if (Category::categoryExists((int) $value)) { $product->id_category[] = (int) $value; } else { $categoryToCreate = new Category(); $categoryToCreate->id = (int) $value; $categoryToCreate->name = self::createMultiLangField($value); $categoryToCreate->active = 1; $categoryToCreate->id_parent = 1; // Default parent is home for unknown category to create if (($fieldError = $categoryToCreate->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $categoryToCreate->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $categoryToCreate->add()) { $product->id_category[] = (int) $categoryToCreate->id; } else { $this->_errors[] = $categoryToCreate->name[$defaultLanguageId] . (isset($categoryToCreate->id) ? ' (' . $categoryToCreate->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } } elseif (is_string($value) and !empty($value)) { $category = Category::searchByName($defaultLanguageId, $value, true); if ($category['id_category']) { $product->id_category[] = (int) $category['id_category']; } else { $categoryToCreate = new Category(); $categoryToCreate->name = self::createMultiLangField($value); $categoryToCreate->active = 1; $categoryToCreate->id_parent = 1; // Default parent is home for unknown category to create if (($fieldError = $categoryToCreate->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $categoryToCreate->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $categoryToCreate->add()) { $product->id_category[] = (int) $categoryToCreate->id; } else { $this->_errors[] = $categoryToCreate->name[$defaultLanguageId] . (isset($categoryToCreate->id) ? ' (' . $categoryToCreate->id . ')' : '') . ' ' . Tools::displayError('Cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } } } } $product->id_category_default = isset($product->id_category[0]) ? (int) $product->id_category[0] : ''; $link_rewrite = is_array($product->link_rewrite) ? $product->link_rewrite[$defaultLanguageId] : ''; $valid_link = Validate::isLinkRewrite($link_rewrite); $bak = $product->link_rewrite; if (isset($product->link_rewrite[$defaultLanguageId]) and empty($product->link_rewrite[$defaultLanguageId]) or !$valid_link) { $link_rewrite = Tools::link_rewrite($product->name[$defaultLanguageId]); if ($link_rewrite == '') { $link_rewrite = 'friendly-url-autogeneration-failed'; } } if (!$valid_link) { $this->_warnings[] = Tools::displayError('Rewrite link for') . ' ' . $bak . (isset($info['id']) ? ' (ID ' . $info['id'] . ') ' : '') . ' ' . Tools::displayError('was re-written as') . ' ' . $link_rewrite; } $product->link_rewrite = self::createMultiLangField($link_rewrite); $res = false; $fieldError = $product->validateFields(UNFRIENDLY_ERROR, true); $langFieldError = $product->validateFieldsLang(UNFRIENDLY_ERROR, true); if ($fieldError === true and $langFieldError === true) { // check quantity if ($product->quantity == NULL) { $product->quantity = 0; } // If id product AND id product already in base, trying to update if ($product->id and Product::existsInDatabase((int) $product->id)) { $datas = Db::getInstance()->getRow('SELECT `date_add` FROM `' . _DB_PREFIX_ . 'product` WHERE `id_product` = ' . (int) $product->id); $product->date_add = pSQL($datas['date_add']); $res = $product->update(); } // If no id_product or update failed if (!$res) { $res = $product->add(); } } // If both failed, mysql error if (!$res) { $this->_errors[] = $info['name'] . (isset($info['id']) ? ' (ID ' . $info['id'] . ')' : '') . ' ' . Tools::displayError('Cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } else { // SpecificPrice (only the basic reduction feature is supported by the import) if (isset($info['reduction_price']) or isset($info['reduction_percent'])) { $specificPrice = new SpecificPrice(); $specificPrice->id_product = (int) $product->id; $specificPrice->id_shop = (int) Shop::getCurrentShop(); $specificPrice->id_currency = 0; $specificPrice->id_country = 0; $specificPrice->id_group = 0; $specificPrice->price = 0.0; $specificPrice->from_quantity = 1; $specificPrice->reduction = (isset($info['reduction_price']) and $info['reduction_price']) ? $info['reduction_price'] : $info['reduction_percent'] / 100; $specificPrice->reduction_type = (isset($info['reduction_price']) and $info['reduction_price']) ? 'amount' : 'percentage'; $specificPrice->from = (isset($info['reduction_from']) and Validate::isDate($info['reduction_from'])) ? $info['reduction_from'] : '0000-00-00 00:00:00'; $specificPrice->to = (isset($info['reduction_to']) and Validate::isDate($info['reduction_to'])) ? $info['reduction_to'] : '0000-00-00 00:00:00'; if (!$specificPrice->add()) { $this->_addProductWarning($info['name'], $product->id, $this->l('Discount is invalid')); } } if (isset($product->tags) and !empty($product->tags)) { // Delete tags for this id product, for no duplicating error Tag::deleteTagsForProduct($product->id); $tag = new Tag(); if (!is_array($product->tags)) { $product->tags = self::createMultiLangField($product->tags); foreach ($product->tags as $key => $tags) { $isTagAdded = $tag->addTags($key, $product->id, $tags); if (!$isTagAdded) { $this->_addProductWarning($info['name'], $product->id, $this->l('Tags list') . ' ' . $this->l('is invalid')); break; } } } else { foreach ($product->tags as $key => $tags) { $str = ''; foreach ($tags as $one_tag) { $str .= $one_tag . ','; } $str = rtrim($str, ','); $isTagAdded = $tag->addTags($key, $product->id, $str); if (!$isTagAdded) { $this->_addProductWarning($info['name'], $product->id, 'Invalid tag(s) (' . $str . ')'); break; } } } } if (isset($product->image) and is_array($product->image) and sizeof($product->image)) { $productHasImages = (bool) Image::getImages((int) $cookie->id_lang, (int) $product->id); foreach ($product->image as $key => $url) { if (!empty($url)) { $image = new Image(); $image->id_product = (int) $product->id; $image->position = Image::getHighestPosition($product->id) + 1; $image->cover = (!$key and !$productHasImages) ? true : false; $image->legend = self::createMultiLangField($product->name[$defaultLanguageId]); 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 { $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(); } } } } if (isset($product->id_category)) { $product->updateCategories(array_map('intval', $product->id_category)); } $features = get_object_vars($product); foreach ($features as $feature => $value) { if (!strncmp($feature, '#F_', 3) and Tools::strlen($product->{$feature})) { $feature_name = str_replace('#F_', '', $feature); $id_feature = Feature::addFeatureImport($feature_name); $id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $product->{$feature}); Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value); } } } } $this->closeCsvFile($handle); }
function content_5627a10d917f36_02598640($_smarty_tpl) { if (isset($_smarty_tpl->tpl_vars['products']->value) && $_smarty_tpl->tpl_vars['products']->value) { ?> <!-- Products list --> <?php if ($_smarty_tpl->tpl_vars['hide_left_column']->value xor $_smarty_tpl->tpl_vars['hide_right_column']->value) { ?> <?php $_smarty_tpl->tpl_vars['ulwidth'] = new Smarty_variable("column3", null, 0); ?> <?php } else { ?> <?php if ($_smarty_tpl->tpl_vars['hide_left_column']->value && $_smarty_tpl->tpl_vars['hide_right_column']->value) { ?> <?php $_smarty_tpl->tpl_vars['ulwidth'] = new Smarty_variable("column4", null, 0); ?> <?php } else { ?> <?php $_smarty_tpl->tpl_vars['ulwidth'] = new Smarty_variable("column2", null, 0); ?> <?php } ?> <?php } ?> <?php if (!isset($_smarty_tpl->tpl_vars['itemWidth']->value)) { ?> <?php $_smarty_tpl->tpl_vars['itemWidth'] = new Smarty_variable(4, null, 0); ?> <?php } ?> <?php if (!isset($_smarty_tpl->tpl_vars['productPerRow']->value)) { ?> <?php $_smarty_tpl->tpl_vars['productPerRow'] = new Smarty_variable(3, null, 0); ?> <?php } ?> <?php $_smarty_tpl->tpl_vars['group_count'] = new Smarty_variable(3, null, 0); ?> <div <?php if (isset($_smarty_tpl->tpl_vars['id']->value) && $_smarty_tpl->tpl_vars['id']->value) { ?> id="<?php echo $_smarty_tpl->tpl_vars['id']->value; ?> "<?php } ?> class="product_list category-grid" data-item-width="<?php echo $_smarty_tpl->tpl_vars['itemWidth']->value; ?> " data-product-per-row="<?php echo $_smarty_tpl->tpl_vars['productPerRow']->value; ?> " > <div class="row"> <?php $_smarty_tpl->tpl_vars['product'] = new Smarty_Variable(); $_smarty_tpl->tpl_vars['product']->_loop = false; $_from = $_smarty_tpl->tpl_vars['products']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } $_smarty_tpl->tpl_vars['product']->total = $_smarty_tpl->_count($_from); $_smarty_tpl->tpl_vars['product']->iteration = 0; $_smarty_tpl->tpl_vars['smarty']->value['foreach']['products']['index'] = -1; foreach ($_from as $_smarty_tpl->tpl_vars['product']->key => $_smarty_tpl->tpl_vars['product']->value) { $_smarty_tpl->tpl_vars['product']->_loop = true; $_smarty_tpl->tpl_vars['product']->iteration++; $_smarty_tpl->tpl_vars['product']->last = $_smarty_tpl->tpl_vars['product']->iteration === $_smarty_tpl->tpl_vars['product']->total; $_smarty_tpl->tpl_vars['smarty']->value['foreach']['products']['index']++; $_smarty_tpl->tpl_vars['smarty']->value['foreach']['products']['last'] = $_smarty_tpl->tpl_vars['product']->last; ?> <?php if ((bool) Configuration::get('PS_DISABLE_OVERRIDES')) { ?> <?php $_smarty_tpl->tpl_vars['over'] = new Smarty_variable(0, null, 0); ?> <?php } else { ?> <?php $_smarty_tpl->tpl_vars['over'] = new Smarty_variable(1, null, 0); ?> <?php $_smarty_tpl->tpl_vars['rate'] = new Smarty_variable(Product::getRatings($_smarty_tpl->tpl_vars['product']->value['id_product']), null, 0); ?> <?php } ?> <?php $_smarty_tpl->tpl_vars['imginfo'] = new Smarty_variable(Image::getImages(Language::getIdByIso($_smarty_tpl->tpl_vars['lang_iso']->value), $_smarty_tpl->tpl_vars['product']->value['id_product']), null, 0); ?> <?php $_smarty_tpl->tpl_vars['new_idimg'] = new Smarty_variable('', null, 0); ?> <?php $_smarty_tpl->tpl_vars['imgitem'] = new Smarty_Variable(); $_smarty_tpl->tpl_vars['imgitem']->_loop = false; $_from = $_smarty_tpl->tpl_vars['imginfo']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars['imgitem']->key => $_smarty_tpl->tpl_vars['imgitem']->value) { $_smarty_tpl->tpl_vars['imgitem']->_loop = true; ?> <?php if (!$_smarty_tpl->tpl_vars['imgitem']->value['cover']) { ?> <?php $_smarty_tpl->tpl_vars['new_idimg'] = new Smarty_variable((string) $_smarty_tpl->tpl_vars['imgitem']->value['id_product'] . "-" . (string) $_smarty_tpl->tpl_vars['imgitem']->value['id_image'], null, 0); ?> <?php break 1; ?> <?php } ?> <?php } ?> <?php $_smarty_tpl->tpl_vars['topLeft'] = new Smarty_variable(false, null, 0); ?> <?php $_smarty_tpl->tpl_vars['topRight'] = new Smarty_variable(false, null, 0); ?> <div class="col-sm-<?php echo $_smarty_tpl->tpl_vars['itemWidth']->value; ?> md-margin2x" itemscope itemtype="http://schema.org/Product"> <div class="product"> <div class="product-top"> <?php if ($_smarty_tpl->tpl_vars['PS_STOCK_MANAGEMENT']->value && isset($_smarty_tpl->tpl_vars['product']->value['available_for_order']) && $_smarty_tpl->tpl_vars['product']->value['available_for_order'] && !isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value)) { ?> <?php if ($_smarty_tpl->tpl_vars['product']->value['quantity'] <= 0) { ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['quantity_all_versions']) && $_smarty_tpl->tpl_vars['product']->value['quantity_all_versions'] > 0) { ?> <link itemprop="availability" href="http://schema.org/LimitedAvailability" /> <span class="outofstock-box top-left"><?php echo smartyTranslate(array('s' => 'Not available', 'mod' => 'simplecategory'), $_smarty_tpl); ?> </span> <?php } else { ?> <link itemprop="availability" href="http://schema.org/OutOfStock" /> <span class="outofstock-box top-left"><?php echo smartyTranslate(array('s' => 'Out of', 'mod' => 'simplecategory'), $_smarty_tpl); ?> <span><?php echo smartyTranslate(array('s' => 'Stock', 'mod' => 'simplecategory'), $_smarty_tpl); ?> </span></span> <?php } ?> <?php } else { ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction']) && $_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction']) { ?> <?php if ($_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction_type'] == 'percentage') { ?> <?php $_smarty_tpl->tpl_vars['topLeft'] = new Smarty_variable(true, null, 0); ?> <span class="discount-box top-left">-<?php echo $_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction'] * 100; ?> %</span> <?php } ?> <?php } else { ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['on_sale']) && $_smarty_tpl->tpl_vars['product']->value['on_sale'] == 1) { ?> <?php $_smarty_tpl->tpl_vars['topLeft'] = new Smarty_variable(true, null, 0); ?> <span class="discount-box top-left"><?php echo smartyTranslate(array('s' => 'Sale'), $_smarty_tpl); ?> </span> <?php } ?> <?php } ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['new']) && $_smarty_tpl->tpl_vars['product']->value['new'] == 1) { ?> <span class="new-box <?php if ($_smarty_tpl->tpl_vars['topLeft']->value == true) { ?> top-right<?php } else { ?> top-left<?php } ?> "><?php echo smartyTranslate(array('s' => 'New'), $_smarty_tpl); ?> </span> <?php } ?> <?php } ?> <?php } else { ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction']) && $_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction']) { ?> <?php if ($_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction_type'] == 'percentage') { ?> <?php $_smarty_tpl->tpl_vars['topLeft'] = new Smarty_variable(true, null, 0); ?> <span class="discount-box top-left">-<?php echo $_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction'] * 100; ?> %</span> <?php } ?> <?php } else { ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['on_sale']) && $_smarty_tpl->tpl_vars['product']->value['on_sale'] == 1) { ?> <?php $_smarty_tpl->tpl_vars['topLeft'] = new Smarty_variable(true, null, 0); ?> <span class="discount-box top-left"><?php echo smartyTranslate(array('s' => 'Sale'), $_smarty_tpl); ?> </span> <?php } ?> <?php } ?> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['new']) && $_smarty_tpl->tpl_vars['product']->value['new'] == 1) { ?> <span class="new-box <?php if ($_smarty_tpl->tpl_vars['topLeft']->value == true) { ?> top-right<?php } else { ?> top-left<?php } ?> "><?php echo smartyTranslate(array('s' => 'New'), $_smarty_tpl); ?> </span> <?php } ?> <?php } ?> <figure class="product-image-container"> <a href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> " title="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); ?> " itemprop="url"> <img class="product-image" src="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value['link_rewrite'], $_smarty_tpl->tpl_vars['product']->value['id_image'], 'home_default'), ENT_QUOTES, 'UTF-8', true); ?> " alt="<?php if (!empty($_smarty_tpl->tpl_vars['product']->value['legend'])) { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['legend'], ENT_QUOTES, 'UTF-8', true); } else { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); } ?> " title="<?php if (!empty($_smarty_tpl->tpl_vars['product']->value['legend'])) { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['legend'], ENT_QUOTES, 'UTF-8', true); } else { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); } ?> " <?php if (isset($_smarty_tpl->tpl_vars['homeSize']->value)) { ?> width="<?php echo $_smarty_tpl->tpl_vars['homeSize']->value['width']; ?> " height="<?php echo $_smarty_tpl->tpl_vars['homeSize']->value['height']; ?> "<?php } ?> itemprop="image" /> <?php if (!empty($_smarty_tpl->tpl_vars['new_idimg']->value)) { ?> <img class="product-image-hover" src="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value['link_rewrite'], $_smarty_tpl->tpl_vars['new_idimg']->value, 'home_default'), ENT_QUOTES, 'UTF-8', true); ?> " alt="<?php if (!empty($_smarty_tpl->tpl_vars['product']->value['legend'])) { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['legend'], ENT_QUOTES, 'UTF-8', true); } else { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); } ?> " title="<?php if (!empty($_smarty_tpl->tpl_vars['product']->value['legend'])) { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['legend'], ENT_QUOTES, 'UTF-8', true); } else { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); } ?> " <?php if (isset($_smarty_tpl->tpl_vars['homeSize']->value)) { ?> width="<?php echo $_smarty_tpl->tpl_vars['homeSize']->value['width']; ?> " height="<?php echo $_smarty_tpl->tpl_vars['homeSize']->value['height']; ?> "<?php } ?> itemprop="image" /> <?php } else { ?> <img class="product-image-hover" src="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value['link_rewrite'], $_smarty_tpl->tpl_vars['product']->value['id_image'], 'home_default'), ENT_QUOTES, 'UTF-8', true); ?> " alt="<?php if (!empty($_smarty_tpl->tpl_vars['product']->value['legend'])) { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['legend'], ENT_QUOTES, 'UTF-8', true); } else { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); } ?> " title="<?php if (!empty($_smarty_tpl->tpl_vars['product']->value['legend'])) { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['legend'], ENT_QUOTES, 'UTF-8', true); } else { echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); } ?> " <?php if (isset($_smarty_tpl->tpl_vars['homeSize']->value)) { ?> width="<?php echo $_smarty_tpl->tpl_vars['homeSize']->value['width']; ?> " height="<?php echo $_smarty_tpl->tpl_vars['homeSize']->value['height']; ?> "<?php } ?> itemprop="image" /> <?php } ?> </a> </figure> <div class="product-action-container"> <div class="product-action-wrapper action-responsive"> <?php if (($_smarty_tpl->tpl_vars['product']->value['id_product_attribute'] == 0 || isset($_smarty_tpl->tpl_vars['add_prod_display']->value) && $_smarty_tpl->tpl_vars['add_prod_display']->value == 1) && $_smarty_tpl->tpl_vars['product']->value['available_for_order'] && !isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value) && $_smarty_tpl->tpl_vars['product']->value['customizable'] != 2 && !$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) { ?> <?php if ((!isset($_smarty_tpl->tpl_vars['product']->value['customization_required']) || !$_smarty_tpl->tpl_vars['product']->value['customization_required']) && ($_smarty_tpl->tpl_vars['product']->value['allow_oosp'] || $_smarty_tpl->tpl_vars['product']->value['quantity'] > 0)) { ?> <?php $_smarty_tpl->_capture_stack[0][] = array('default', null, null); ob_start(); ?> add=1&id_product=<?php echo intval($_smarty_tpl->tpl_vars['product']->value['id_product']); if (isset($_smarty_tpl->tpl_vars['static_token']->value)) { ?> &token=<?php echo $_smarty_tpl->tpl_vars['static_token']->value; } list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]); if (!empty($_capture_buffer)) { if (isset($_capture_assign)) { $_smarty_tpl->assign($_capture_assign, ob_get_contents()); } if (isset($_capture_append)) { $_smarty_tpl->append($_capture_append, ob_get_contents()); } Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean(); } else { $_smarty_tpl->capture_error(); } ?> <a class="ajax_add_to_cart_button product-add-btn" href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getPageLink('cart', true, null, Smarty::$_smarty_vars['capture']['default'], false), ENT_QUOTES, 'UTF-8', true); ?> " rel="nofollow" title="<?php echo smartyTranslate(array('s' => 'Add to cart'), $_smarty_tpl); ?> " data-id-product="<?php echo intval($_smarty_tpl->tpl_vars['product']->value['id_product']); ?> " data-minimal_quantity="<?php if (isset($_smarty_tpl->tpl_vars['product']->value['product_attribute_minimal_quantity']) && $_smarty_tpl->tpl_vars['product']->value['product_attribute_minimal_quantity'] > 1) { echo intval($_smarty_tpl->tpl_vars['product']->value['product_attribute_minimal_quantity']); } else { echo intval($_smarty_tpl->tpl_vars['product']->value['minimal_quantity']); } ?> "> <span class="add-btn-text"><?php echo smartyTranslate(array('s' => 'Add to Cart', 'mod' => 'simplecategory'), $_smarty_tpl); ?> </span> <span class="product-btn product-cart"><?php echo smartyTranslate(array('s' => 'Cart', 'mod' => 'simplecategory'), $_smarty_tpl); ?> </span> </a> <?php } else { ?> <span class="ajax_add_to_cart_button product-add-btn disabled"> <span class="add-btn-text"><?php echo smartyTranslate(array('s' => 'Add to Cart', 'mod' => 'simplecategory'), $_smarty_tpl); ?> </span> <span class="product-btn product-cart"><?php echo smartyTranslate(array('s' => 'Cart', 'mod' => 'simplecategory'), $_smarty_tpl); ?> </span> </span> <?php } ?> <?php } ?> <?php if (isset($_smarty_tpl->tpl_vars['quick_view']->value) && $_smarty_tpl->tpl_vars['quick_view']->value) { ?> <a href="javascript:void(0)" title="<?php echo smartyTranslate(array('s' => 'Quick view'), $_smarty_tpl); ?> " data-rel="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> " class="quick-view product-btn product-search"></a> <?php } ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => 'displayProductListFunctionalButtons', 'product' => $_smarty_tpl->tpl_vars['product']->value), $_smarty_tpl); ?> <?php if (isset($_smarty_tpl->tpl_vars['comparator_max_item']->value) && $_smarty_tpl->tpl_vars['comparator_max_item']->value) { ?> <a href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> " title="<?php echo smartyTranslate(array('s' => 'Add to compare'), $_smarty_tpl); ?> " class="add_to_compare link-compare product-btn product-compare" data-id-product="<?php echo $_smarty_tpl->tpl_vars['product']->value['id_product']; ?> "></a> <!-- <a class="add_to_compare product-btn link-compare" title="<?php echo smartyTranslate(array('s' => 'Add to compare'), $_smarty_tpl); ?> " href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> " data-id-product="<?php echo $_smarty_tpl->tpl_vars['product']->value['id_product']; ?> "><?php echo smartyTranslate(array('s' => 'Add to compare'), $_smarty_tpl); ?> </a> --> <?php } ?> </div> </div> </div> <h3 class="product-name" itemprop="name"> <a href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['link'], ENT_QUOTES, 'UTF-8', true); ?> " title="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value['name'], ENT_QUOTES, 'UTF-8', true); ?> " itemprop="url" > <?php echo htmlspecialchars($_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['truncate'][0][0]->smarty_modifier_truncate($_smarty_tpl->tpl_vars['product']->value['name'], 32, ''), ENT_QUOTES, 'UTF-8', true); ?> </a> </h3> <div class="ratings-container"> <?php if ($_smarty_tpl->tpl_vars['over']->value == 1) { ?> <div class="ratings" itemprop="aggregateRating" itemscope="" itemtype="http://schema.org/AggregateRating"> <div class="ratings-result" data-result="<?php echo $_smarty_tpl->tpl_vars['rate']->value['avg']; ?> "></div> <meta itemprop="worstRating" content="<?php echo $_smarty_tpl->tpl_vars['rate']->value['min']; ?> "> <meta itemprop="ratingValue" content="<?php echo $_smarty_tpl->tpl_vars['rate']->value['avg']; ?> "> <meta itemprop="bestRating" content="<?php echo $_smarty_tpl->tpl_vars['rate']->value['max']; ?> "> <meta itemprop="reviewCount" content="<?php echo $_smarty_tpl->tpl_vars['rate']->value['review']; ?> "> </div> <!-- <span class="ratings-amount"><?php echo $_smarty_tpl->tpl_vars['rate']->value['review']; ?> review(s)</span> --> <?php } else { ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => 'displayProductListReviews', 'product' => $_smarty_tpl->tpl_vars['product']->value), $_smarty_tpl); ?> <?php } ?> </div> <p class="product-desc" itemprop="description"> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['truncate'][0][0]->smarty_modifier_truncate(strip_tags($_smarty_tpl->tpl_vars['product']->value['description_short']), 360, '...'); ?> </p> <div class="product-price-container"> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['show_price']) && $_smarty_tpl->tpl_vars['product']->value['show_price'] && !isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value)) { ?> <meta itemprop="priceCurrency" content="<?php echo $_smarty_tpl->tpl_vars['currency']->value->iso_code; ?> " /> <?php if (isset($_smarty_tpl->tpl_vars['product']->value['specific_prices']) && $_smarty_tpl->tpl_vars['product']->value['specific_prices'] && isset($_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction']) && $_smarty_tpl->tpl_vars['product']->value['specific_prices']['reduction'] > 0) { ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "old_price"), $_smarty_tpl); ?> <span class="product-old-price"><?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['displayWtPrice'][0][0]->displayWtPrice(array('p' => $_smarty_tpl->tpl_vars['product']->value['price_without_reduction']), $_smarty_tpl); ?> </span> <span class="product-price" itemprop="price"><?php if (!$_smarty_tpl->tpl_vars['priceDisplay']->value) { echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['product']->value['price']), $_smarty_tpl); } else { echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['product']->value['price_tax_exc']), $_smarty_tpl); } ?> </span> <?php } else { ?> <span class="product-price" itemprop="price"> <?php if (!$_smarty_tpl->tpl_vars['priceDisplay']->value) { echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['product']->value['price']), $_smarty_tpl); } else { echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['product']->value['price_tax_exc']), $_smarty_tpl); } ?> </span> <?php } ?> <?php } ?> </div> </div> </div> <?php if ($_smarty_tpl->getVariable('smarty')->value['foreach']['products']['index'] % $_smarty_tpl->tpl_vars['productPerRow']->value == $_smarty_tpl->tpl_vars['productPerRow']->value - 1 && !$_smarty_tpl->getVariable('smarty')->value['foreach']['products']['last']) { ?> </div> <div class="row"> <?php } ?> <?php } ?> </div> </div> <?php $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'min_item')); $_block_repeat = true; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'min_item'), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); echo smartyTranslate(array('s' => 'Please select at least one product', 'js' => 1), $_smarty_tpl); $_block_content = ob_get_clean(); $_block_repeat = false; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'min_item'), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> <?php $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'max_item')); $_block_repeat = true; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'max_item'), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); echo smartyTranslate(array('s' => 'You cannot add more than %d product(s) to the product comparison', 'sprintf' => $_smarty_tpl->tpl_vars['comparator_max_item']->value, 'js' => 1), $_smarty_tpl); $_block_content = ob_get_clean(); $_block_repeat = false; echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'max_item'), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('comparator_max_item' => $_smarty_tpl->tpl_vars['comparator_max_item']->value), $_smarty_tpl); ?> <?php echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('comparedProductsIds' => $_smarty_tpl->tpl_vars['compared_products']->value), $_smarty_tpl); ?> <?php } }
public function sendCampaign() { // get abandoned cart : $sql = "SELECT * FROM (\n\t\tSELECT\n\t\tCONCAT(LEFT(c.`firstname`, 1), '. ', c.`lastname`) `customer`, a.id_cart total, ca.name carrier, c.id_customer, a.id_cart, a.date_upd,a.date_add,\n\t\t\t\tIF (IFNULL(o.id_order, 'Non ordered') = 'Non ordered', IF(TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', a.`date_add`)) > 86000, 'Abandoned cart', 'Non ordered'), o.id_order) id_order, IF(o.id_order, 1, 0) badge_success, IF(o.id_order, 0, 1) badge_danger, IF(co.id_guest, 1, 0) id_guest\n\t\tFROM `" . _DB_PREFIX_ . "cart` a \n\t\t\t\tJOIN `" . _DB_PREFIX_ . "customer` c ON (c.id_customer = a.id_customer)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "currency` cu ON (cu.id_currency = a.id_currency)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "carrier` ca ON (ca.id_carrier = a.id_carrier)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "orders` o ON (o.id_cart = a.id_cart)\n\t\t\t\tLEFT JOIN `" . _DB_PREFIX_ . "connections` co ON (a.id_guest = co.id_guest AND TIME_TO_SEC(TIMEDIFF('" . date('Y-m-d H:i:s') . "', co.`date_add`)) < 1800)\n\t\t\t\tWHERE a.date_add > (NOW() - INTERVAL 60 DAY) ORDER BY a.id_cart DESC \n\t\t) AS toto WHERE id_order='Abandoned cart'"; $currency = Context::getContext()->currency->sign; $defaultLanguage = new Language((int) Configuration::get('PS_LANG_DEFAULT')); $abandoned_carts = Db::getInstance()->ExecuteS($sql); // get all available campaigns $sqlCampaigns = 'SELECT * FROM `' . _DB_PREFIX_ . 'campaign` WHERE active=1'; $allCampaigns = Db::getInstance()->ExecuteS($sqlCampaigns); if (!$allCampaigns || empty($allCampaigns)) { die('NO CAMPAIGN'); } // loop on all abandoned carts foreach ($abandoned_carts as $abncart) { if (Cart::getNbProducts((int) $abncart['id_cart']) > 0) { $emailsSent = 0; // loop on all available campaigns foreach ($allCampaigns as $camp) { if (DEBUG_SAC) { echo 'IdCustomer : ' . $abncart['id_customer'] . ' - IdCart : ' . $abncart['id_cart'] . '<br/>'; } $cartIsOnCampaign = $this->checkIfCartIsOnCampaign($abncart['date_add'], $camp['execution_time_day'], $camp['execution_time_hour']); if ($cartIsOnCampaign) { if (DEBUG_SAC) { echo 'Cart on campaign</br>'; } $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); $customer = new Customer($abncart['id_customer']); $cart = new Cart($abncart['id_cart']); $products = $cart->getProducts(); $tpl_vars = array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{campaign_name}' => $camp['name'], '{track_url}' => $this->getBaseURL() . '?id_cart=' . (int) $abncart['id_cart'] . '&id_customer=' . (int) $abncart['id_customer'], '{track_request}' => '?id_cart=' . (int) $abncart['id_cart'] . '&id_customer=' . (int) $abncart['id_customer']); $campM = new Campaign($camp['id_campaign']); if ($campM->voucher_amount && $campM->voucher_day && $campM->voucher_amount_type) { $campM->clean_old_reduction($campM->voucher_prefix); $customerVoucher = $campM->registerDiscount($customer->id, $campM->voucher_amount, $campM->voucher_day, $campM->voucher_amount_type, $campM->voucher_prefix); $tpl_vars['{coupon_name}'] = $customerVoucher->name; $tpl_vars['{coupon_code}'] = $customerVoucher->code; $tpl_vars['{coupon_value}'] = $camp['voucher_amount_type'] == 'percent' ? $customerVoucher->reduction_percent . '%' : Tools::displayprice($customerVoucher->reduction_amount); $tpl_vars['{coupon_valid_to}'] = date('d/m/Y', strtotime($customerVoucher->date_to)); } if (!empty($products)) { $cart_content = $campM->getCartContentHeader(); } else { $cart_content = ''; } foreach ($products as $prod) { $p = new Product($prod['id_product'], true, $id_lang); $price_no_tax = Product::getPriceStatic($p->id, false, null, 2, null, false, true, 1, false, null, $abncart['id_cart'], null, $null, true, true, null, false, false); $total_no_tax = $prod['cart_quantity'] * $price_no_tax; $images = Image::getImages((int) $id_lang, (int) $p->id); $link = new Link(); $cart_content .= '<tr> <td align="center" ><img src="' . Tools::getShopProtocol() . $link->getImageLink($p->link_rewrite, $images[0]['id_image']) . '" width="80"/></td> <td align="center" ><a href="' . $link->getProductLink($p) . '?id_cart=' . (int) $abncart['id_cart'] . '&id_customer=' . (int) $abncart['id_customer'] . '"/>' . $p->name . '</a></td> <td align="center" >' . Tools::displayprice($price_no_tax) . '</td> <td align="center" >' . $prod['cart_quantity'] . '</td> <td align="center" >' . Tools::displayprice($total_no_tax) . '</td> </tr>'; } $cart_content .= '</table>'; $tpl_vars['{cart_content}'] = $cart_content; $path = _PS_ROOT_DIR_ . '/modules/superabandonedcart/mails/'; // send email to customer : $mailUser = Mail::Send($id_lang, $campM->getFileName(), $camp['name'], $tpl_vars, $customer->email, null, null, null, null, null, $path, false, Context::getContext()->shop->id); // if mail user is successfully sent : if ($mailUser) { $history = new CampaignHistory(); $history->id_campaign = (int) $camp['id_campaign']; $history->id_customer = $abncart['id_customer']; $history->id_cart = $abncart['id_cart']; $history->id_cart_rule = isset($customerVoucher->id) ? $customerVoucher->id : 0; $history->click = 0; $history->converted = 0; $history->date_update = date('Y-m-d H:i:s', time()); $history->save(); // Email to admin : Mail::Send($id_lang, $campM->getFileName(), Mail::l(sprintf('Email sent to %s %s for campaign %s', $customer->lastname, $customer->firstname, $camp['name'])), $tpl_vars, Configuration::get('PS_SHOP_EMAIL'), null, null, null, null, null, $path, false, Context::getContext()->shop->id); ++$emailsSent; } else { PrestaShopLogger::addLog('Error when sending user email (tpl:' . $campM->getFileName() . ',customer:' . $customer->email . ', campagne : ' . $camp['name'], 3); } } } // log emailing results : if ($emailsSent > 0) { PrestaShopLogger::addLog($emailsSent . ' emails sent for ' . $camp['name'] . ' campaign', 1); } } } }
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>'; } }
return false; } function createThumb($file) { if (!$this->File->checkIfFileExists($this->rutaThumb . $file)) { $this->System->execCommand(); } echo "<a href=" . $this->rutaFoto . $file . "><img src=" . $this->rutaThumb . $file . "></a>"; } function getImages() { } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" httpequiv="content-type"> </head> <body> <?php echo "<h1>GALERÍA DE FOTOS EN PHP</h1>"; $path = "fotos"; $image = new Image($path); $image_list = $image->getImages(); ?> </body> </html>
<title><![CDATA[<?php echo Configuration::get('PS_SHOP_NAME'); ?> ]]></title> <url><?php echo _PS_BASE_URL_ . __PS_BASE_URI__ . 'img/logo.jpg'; ?> </url> <link><?php echo _PS_BASE_URL_ . __PS_BASE_URI__; ?> </link> </image> <?php foreach ($products as $product) { $image = Image::getImages((int) $cookie->id_lang, $product['id_product']); echo "\t\t<item>\n"; echo "\t\t\t<title><![CDATA[" . $product['name'] . " - " . html_entity_decode(Tools::displayPrice(Product::getPriceStatic($product['id_product']), $currency), ENT_COMPAT, 'UTF-8') . " ]]></title>\n"; echo "\t\t\t<description>"; $cdata = true; if (is_array($image) and sizeof($image)) { $imageObj = new Image($image[0]['id_image']); echo "<![CDATA[<img src='" . $link->getImageLink($product['link_rewrite'], $image[0]['id_image'], 'small_default') . "' title='" . str_replace('&', '', $product['name']) . "' alt='thumb' />"; $cdata = false; } if ($cdata) { echo "<![CDATA["; } echo $product['description_short'] . "]]></description>\n"; echo "\t\t\t<link><![CDATA[" . str_replace('&', '&', htmlspecialchars($link->getproductLink($product['id_product'], $product['link_rewrite'], Category::getLinkRewrite((int) $product['id_category_default'], $cookie->id_lang)))) . $affiliate . "]]></link>\n"; echo "\t\t</item>\n";
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.")); } }
<?php error_reporting(0); header('Content-Type:text/html;charset=utf8'); require 'include/DB.class.php'; require 'include/Image.class.php'; $results = Image::getImages(); ?> <!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>图片情感标签标注系统-主页</title> <script type="text/javascript" src="js/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="style/basic.css"> <link rel="stylesheet" type="text/css" href="style/index.css"> <script type="text/javascript" src="js/index.js"></script> <script type="text/javascript" src="js/upload.js"></script> </head> <body> <?php require 'include/header.inc.php'; ?> <div id="main"> <div id="bar"> <ul> <li class="select">愉快</li> <li>期望</li> <li>惊讶</li> <li>恐惧</li>
public function productImport() { global $cookie; $this->receiveTab(); $handle = $this->openCsvFile(); $defaultLanguageId = intval(Configuration::get('PS_LANG_DEFAULT')); 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); if (array_key_exists('id', $info) and intval($info['id']) and Product::existsInDatabase(intval($info['id']))) { $product = new Product(intval($info['id'])); if ($product->reduction_from == '0000-00-00') { $product->reduction_from = date('Y-m-d'); } if ($product->reduction_to == '0000-00-00') { $product->reduction_to = date('Y-m-d'); } $categoryData = Product::getIndexedCategories(intval($product->id)); foreach ($categoryData as $tmp) { $product->category[] = $tmp['id_category']; } } else { $product = new Product(); } self::setEntityDefaultValues($product); self::array_walk($info, array('AdminImport', 'fillInfo'), $product); // Find id_tax corresponding to given values for product taxe if (isset($product->tax_rate)) { $product->id_tax = intval(Tax::getTaxIdByRate(floatval($product->tax_rate))); } if (isset($product->tax_rate) and !$product->id_tax) { $tax = new Tax(); $tax->rate = floatval($product->tax_rate); $tax->name = self::createMultiLangField(strval($product->tax_rate)); if (($fieldError = $tax->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $tax->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $tax->add()) { $product->id_tax = intval($tax->id); } else { $this->_errors[] = 'TAX ' . $tax->name[$defaultLanguageId] . ' ' . Tools::displayError('cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } if (isset($product->manufacturer) and is_numeric($product->manufacturer) and Manufacturer::manufacturerExists(intval($product->manufacturer))) { $product->id_manufacturer = intval($product->manufacturer); } elseif (isset($product->manufacturer) and is_string($product->manufacturer) and !empty($product->manufacturer)) { if ($manufacturer = Manufacturer::getIdByName($product->manufacturer)) { $product->id_manufacturer = intval($manufacturer); } else { $manufacturer = new Manufacturer(); $manufacturer->name = $product->manufacturer; if (($fieldError = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $manufacturer->add()) { $product->id_manufacturer = intval($manufacturer->id); } else { $this->_errors[] = $manufacturer->name . (isset($manufacturer->id) ? ' (' . $manufacturer->id . ')' : '') . ' ' . Tools::displayError('cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } } if (isset($product->supplier) and is_numeric($product->supplier) and Supplier::supplierExists(intval($product->supplier))) { $product->id_supplier = intval($product->supplier); } elseif (isset($product->supplier) and is_string($product->supplier) and !empty($product->supplier)) { if ($supplier = Supplier::getIdByName($product->supplier)) { $product->id_supplier = intval($supplier); } else { $supplier = new Supplier(); $supplier->name = $product->supplier; if (($fieldError = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $supplier->add()) { $product->id_supplier = intval($supplier->id); } else { $this->_errors[] = $supplier->name . (isset($supplier->id) ? ' (' . $supplier->id . ')' : '') . ' ' . Tools::displayError('cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } } if (isset($product->price_tex) and !isset($product->price_tin)) { $product->price = $product->price_tex; } elseif (isset($product->price_tin) and !isset($product->price_tex)) { $product->price = $product->price_tin; // If a tax is already included in price, withdraw it from price if ($product->tax_rate) { $product->price = floatval(number_format($product->price / (1 + $product->tax_rate / 100), 6)); } } elseif (isset($product->price_tin) and isset($product->price_tex)) { $product->price = $product->price_tex; } if (isset($product->category) and is_array($product->category) and sizeof($product->category)) { $product->id_category = array(); // Reset default values array foreach ($product->category as $value) { if (is_numeric($value)) { if (Category::categoryExists(intval($value))) { $product->id_category[] = intval($value); } else { $categoryToCreate = new Category(); $categoryToCreate->id = intval($value); $categoryToCreate->name = self::createMultiLangField($value); $categoryToCreate->active = 1; $categoryToCreate->id_parent = 1; // Default parent is home for unknown category to create if (($fieldError = $categoryToCreate->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $categoryToCreate->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $categoryToCreate->add()) { $product->id_category[] = intval($categoryToCreate->id); } else { $this->_errors[] = $categoryToCreate->name[$defaultLanguageId] . (isset($categoryToCreate->id) ? ' (' . $categoryToCreate->id . ')' : '') . ' ' . Tools::displayError('cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } } elseif (is_string($value) and !empty($value)) { $category = Category::searchByName($defaultLanguageId, $value, true); if ($category['id_category']) { $product->id_category[] = intval($category['id_category']); } else { $categoryToCreate = new Category(); $categoryToCreate->name = self::createMultiLangField($value); $categoryToCreate->active = 1; $categoryToCreate->id_parent = 1; // Default parent is home for unknown category to create if (($fieldError = $categoryToCreate->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $categoryToCreate->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $categoryToCreate->add()) { $product->id_category[] = intval($categoryToCreate->id); } else { $this->_errors[] = $categoryToCreate->name[$defaultLanguageId] . (isset($categoryToCreate->id) ? ' (' . $categoryToCreate->id . ')' : '') . ' ' . Tools::displayError('cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } } } } } $product->id_category_default = isset($product->id_category[0]) ? intval($product->id_category[0]) : ''; $link_rewrite = is_array($product->link_rewrite) ? $product->link_rewrite[$defaultLanguageId] : ''; $valid_link = Validate::isLinkRewrite($link_rewrite); $bak = $product->link_rewrite; if (isset($product->link_rewrite[$defaultLanguageId]) and empty($product->link_rewrite[$defaultLanguageId]) or !$valid_link) { $link_rewrite = Tools::link_rewrite($product->name[$defaultLanguageId]); } if (!$valid_link) { $this->_warnings[] = Tools::displayError('Rewrited link for') . ' ' . $bak . (isset($info['id']) ? ' (ID ' . $info['id'] . ') ' : '') . ' ' . Tools::displayError('was re-written as') . ' ' . $link_rewrite; } $product->link_rewrite = self::createMultiLangField($link_rewrite); $res = false; $fieldError = $product->validateFields(UNFRIENDLY_ERROR, true); $langFieldError = $product->validateFieldsLang(UNFRIENDLY_ERROR, true); if ($fieldError === true and $langFieldError === true) { // check quantity if ($product->quantity == NULL) { $product->quantity = 0; } // If id product AND id product already in base, trying to update if ($product->id and Product::existsInDatabase(intval($product->id))) { $datas = Db::getInstance()->getRow('SELECT `date_add` FROM `' . _DB_PREFIX_ . 'product` WHERE `id_product` = ' . intval($product->id)); $product->date_add = pSQL($datas['date_add']); $res = $product->update(); } // If no id_product or update failed if (!$res) { $res = $product->add(); } } // If both failed, mysql error if (!$res) { $this->_errors[] = $info['name'] . (isset($info['id']) ? ' (ID ' . $info['id'] . ')' : '') . ' ' . Tools::displayError('cannot be saved'); $this->_errors[] = ($fieldError !== true ? $fieldError : '') . ($langFieldError !== true ? $langFieldError : '') . mysql_error(); } else { if (isset($product->tags) and !empty($product->tags)) { $tag = new Tag(); $array = self::createMultiLangField($product->tags); foreach ($array as $key => $tags) { $a = $tag->addTags($key, $product->id, $tags); } } if (isset($product->image) and is_array($product->image) and sizeof($product->image)) { $productHasImages = (bool) Image::getImages(intval($cookie->id_lang), intval($product->id)); foreach ($product->image as $key => $url) { if (!empty($url)) { $image = new Image(); $image->id_product = intval($product->id); $image->position = Image::getHighestPosition($product->id) + 1; $image->cover = (!$key and !$productHasImages) ? true : false; $image->legend = self::createMultiLangField($product->name[$defaultLanguageId]); if (($fieldError = $image->validateFields(UNFRIENDLY_ERROR, true)) === true and ($langFieldError = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true and $image->add()) { self::copyImg($product->id, $image->id, $url); } 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(); } } } } if (isset($product->id_category)) { $product->updateCategories(array_map('intval', $product->id_category)); } $features = get_object_vars($product); foreach ($features as $feature => $value) { if (!strncmp($feature, '#F_', 3) and Tools::strlen($product->{$feature})) { $feature_name = str_replace('#F_', '', $feature); $id_feature = Feature::addFeatureImport($feature_name); $id_feature_value = FeatureValue::addFeatureValueImport($id_feature, $product->{$feature}); Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value); } } } } $this->closeCsvFile($handle); }
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 makeData($product, $combination = false) { $params = array(); $data = array(); $images = array(); $id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); if ($combination) { $quantity = (int) $combination['quantity']; $url = $product['link'] . '#' . $combination['comb_url']; $price = Tools::ps_round($combination['price'], 2); $reference = $combination['reference']; $id_offer = $product['id_product'] . 'c' . $combination['id_product_attribute']; $barcode = $combination['ean13']; $images = Image::getImages($id_lang, $product['id_product'], $combination['id_product_attribute']); if (empty($images)) { $images = Image::getImages($id_lang, $product['id_product']); } if ((int) $combination['weight'] > 0) { $data['weight'] = $combination['weight']; $data['weight'] = number_format($data['weight'], 2); } else { $data['weight'] = $product['weight']; $data['weight'] = number_format($data['weight'], 2); } if ($combination['minimal_quantity'] > 1) { $data['sales_notes'] = $this->l('Minimum order') . ' ' . $combination['minimal_quantity'] . ' ' . $this->l('of the product (s)'); } } else { $quantity = (int) $product['quantity']; $url = $product['link']; $price = Tools::ps_round($product['price'], 2); $reference = $product['reference']; $id_offer = $product['id_product']; $barcode = $product['ean13']; $images = Image::getImages($id_lang, $product['id_product']); if ((int) $product['weight'] > 0) { $data['weight'] = $product['weight']; $data['weight'] = number_format($data['weight'], 2); } if ($product['minimal_quantity'] > 1) { $data['sales_notes'] = $this->l('Minimum order') . ' ' . $product['minimal_quantity'] . ' ' . $this->l('of the product (s)'); } } if (Configuration::get('YA_MARKET_SET_AVAILABLE')) { if ($quantity < 1) { return; } } $available = 'false'; if ($this->yamarket_availability == 0) { $available = 'true'; } elseif ($this->yamarket_availability == 1) { if ($quantity > 0) { $available = 'true'; } } elseif ($this->yamarket_availability == 2) { $available = 'true'; if ($quantity == 0) { return; } } if ($product['features']) { foreach ($product['features'] as $feature) { $params[$feature['name']] = $feature['value']; } } if ($combination) { $params = array_merge($params, $combination['attributes']); } $data['available'] = $available; $data['url'] = str_replace('https://', 'http://', $url); $data['id'] = $id_offer; $data['currencyId'] = $this->currency_iso; $data['price'] = $price; $data['categoryId'] = $product['id_category_default']; /*-------------------------------------------------------------------*/ preg_match_all('/([а-яё]+)/iu', $data['url'], $urlarr, PREG_SET_ORDER); if (!empty($urlarr)) { foreach ($urlarr as $ua) { $data['url'] = str_replace($ua[0], rawurlencode($ua[0]), $data['url']); } } /*-------------------------------------------------------------------*/ foreach ($images as $i) { $uri = $this->context->link->getImageLink($product['link_rewrite'], $i['id_image']); preg_match_all('/([а-яё]+)/iu', $uri, $marr, PREG_SET_ORDER); if (!empty($marr)) { foreach ($marr as $m) { $uri = str_replace($m[0], rawurlencode($m[0]), $uri); } } $data['picture'][] = $uri; } if (!Configuration::get('YA_MARKET_SHORT')) { $data['model'] = $product['name']; if (Configuration::get('YA_MARKET_SET_DIMENSIONS') && $product['height'] > 0 && $product['depth'] > 0 && $product['width']) { $data['dimensions'] = number_format($product['depth'], 3, '.', '') . '/' . number_format($product['width'], 3, '.', '') . '/' . number_format($product['height'], 3, '.', ''); } if ($product['is_virtual']) { $data['downloadable'] = 'true'; } else { $data['downloadable'] = 'false'; } if (Configuration::get('YA_MARKET_DESC_TYPE')) { $data['description'] = $product['description_short']; } else { $data['description'] = $product['description']; } $data['param'] = $params; } else { $data['name'] = $product['name']; } $data['vendor'] = $product['manufacturer_name']; $data['barcode'] = $barcode; $data['delivery'] = 'false'; $data['pickup'] = 'false'; $data['store'] = 'false'; $data['vendorCode'] = $reference; if (Configuration::get('YA_MARKET_SET_DOST')) { $data['delivery'] = 'true'; } if (Configuration::get('YA_MARKET_SET_SAMOVIVOZ')) { $data['pickup'] = 'true'; } if (Configuration::get('YA_MARKET_SET_ROZNICA')) { $data['store'] = 'true'; } return $data; }
protected function manageEntityDeclinatedImages($directory, $normal_image_sizes) { $normal_image_size_names = array(); foreach ($normal_image_sizes as $normal_image_size) { $normal_image_size_names[] = $normal_image_size['name']; } // If id is detected $object_id = $this->wsObject->urlSegment[2]; if (!Validate::isUnsignedId($object_id)) { throw new WebserviceException('The image id is invalid. Please set a valid id or the "default" value', array(60, 400)); } // For the product case if ($this->imageType == 'products') { // Get available image ids $available_image_ids = array(); // New Behavior $languages = Language::getLanguages(); foreach ($languages as $language) { foreach (Image::getImages($language['id_lang'], $object_id) as $image) { $available_image_ids[] = $image['id_image']; } } // If an image id is specified if ($this->wsObject->urlSegment[3] != '') { if ($this->wsObject->urlSegment[3] == 'bin') { $currentProduct = new Product($object_id); $this->wsObject->urlSegment[3] = $currentProduct->getCoverWs(); } if (!Validate::isUnsignedId($object_id) || !in_array($this->wsObject->urlSegment[3], $available_image_ids)) { throw new WebserviceException('This image id does not exist', array(57, 400)); } else { // Check for new image system $image_id = $this->wsObject->urlSegment[3]; $path = implode('/', str_split((string) $image_id)); $image_size = $this->wsObject->urlSegment[4]; if (file_exists($directory . $path . '/' . $image_id . (strlen($this->wsObject->urlSegment[4]) > 0 ? '-' . $this->wsObject->urlSegment[4] : '') . '.jpg')) { $filename = $directory . $path . '/' . $image_id . (strlen($this->wsObject->urlSegment[4]) > 0 ? '-' . $this->wsObject->urlSegment[4] : '') . '.jpg'; $orig_filename = $directory . $path . '/' . $image_id . '.jpg'; } else { $orig_filename = $directory . $object_id . '-' . $image_id . '.jpg'; $filename = $directory . $object_id . '-' . $image_id . '-' . $image_size . '.jpg'; } } } else { if ($this->wsObject->method == 'GET' || $this->wsObject->method == 'HEAD') { if ($available_image_ids) { $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('image', array(), array('id' => $object_id)); foreach ($available_image_ids as $available_image_id) { $this->output .= $this->objOutput->getObjectRender()->renderNodeHeader('declination', array(), array('id' => $available_image_id, 'xlink_resource' => $this->wsObject->wsUrl . 'images/' . $this->imageType . '/' . $object_id . '/' . $available_image_id), false); } $this->output .= $this->objOutput->getObjectRender()->renderNodeFooter('image', array()); } else { $this->objOutput->setStatus(404); $this->wsObject->setOutputEnabled(false); } } } } else { $orig_filename = $directory . $object_id . '.jpg'; $image_size = $this->wsObject->urlSegment[3]; $filename = $directory . $object_id . '-' . $image_size . '.jpg'; } // in case of declinated images list of a product is get if ($this->output != '') { return true; } elseif (isset($image_size) && $image_size != '') { // Check the given size if ($this->imageType == 'products' && $image_size == 'bin') { $filename = $directory . $object_id . '-' . $image_id . '.jpg'; } elseif (!in_array($image_size, $normal_image_size_names)) { $exception = new WebserviceException('This image size does not exist', array(58, 400)); throw $exception->setDidYouMean($image_size, $normal_image_size_names); } if (!file_exists($filename)) { throw new WebserviceException('This image does not exist on disk', array(59, 500)); } // Display the resized specific image $this->imgToDisplay = $filename; return true; } elseif (isset($orig_filename)) { $orig_filename_exists = file_exists($orig_filename); return $this->manageDeclinatedImagesCRUD($orig_filename_exists, $orig_filename, $normal_image_sizes, $directory); } else { return $this->manageDeclinatedImagesCRUD(false, '', $normal_image_sizes, $directory); } }
/** * get all the uploaded images along with their description and votes count * @return array */ public function getAllImages() { $Object = new Image(); $result = $Object->getImages(); return $result; }
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 static function addProductImage($id_product, $url) { ${"GLOBALS"}["fvripywkibk"] = "url"; $ebptnhakfo = "url"; ${"GLOBALS"}["sipzolomo"] = "url"; ${${"GLOBALS"}["fvripywkibk"]} = trim(${${"GLOBALS"}["sipzolomo"]}); $irpunjy = "id_product"; if (empty(${$ebptnhakfo})) { return false; } ${"GLOBALS"}["dbttbk"] = "product_has_images"; ${"GLOBALS"}["ngbttfrcas"] = "url"; ${${"GLOBALS"}["ngbttfrcas"]} = str_replace(" ", "%20", ${${"GLOBALS"}["qqvbhasckjhp"]}); ${${"GLOBALS"}["dbttbk"]} = (bool) Image::getImages(Context::getContext()->language->id, (int) ${${"GLOBALS"}["fhxsdwr"]}); ${${"GLOBALS"}["jbswpeulv"]} = new Image(); $image->id_product = (int) ${$irpunjy}; $image->position = Image::getHighestPosition(${${"GLOBALS"}["fhxsdwr"]}) + 1; $image->cover = ${${"GLOBALS"}["ntduigxet"]} ? false : true; if ($image->validateFields(false, true) === true && $image->validateFieldsLang(false, true) === true && $image->add()) { $otsljdt = "url"; $jpwhwuiglhb = "id_product"; $image->associateTo(array(1)); return AgileHelper::copyImg(${$jpwhwuiglhb}, $image->id, ${$otsljdt}, "products", !Tools::getValue("regenerate")); } return false; }