本文整理汇总了PHP中Link::getImageLink方法的典型用法代码示例。如果您正苦于以下问题:PHP Link::getImageLink方法的具体用法?PHP Link::getImageLink怎么用?PHP Link::getImageLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::getImageLink方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateImageLink
protected static function generateImageLink($product, $ps_product, $id_lang, $iso_code)
{
$link = new Link();
$cover = Image::getCover($ps_product->id);
$product->{"image_link_small_{$iso_code}"} = $link->getImageLink($ps_product->link_rewrite[$id_lang], $cover["id_image"], ImageType::getFormatedName("small"));
$product->{"image_link_large_{$iso_code}"} = $link->getImageLink($ps_product->link_rewrite[$id_lang], $cover["id_image"], ImageType::getFormatedName("large"));
return $product;
}
示例2: formatProduct
protected function formatProduct($id_product, $id_lang)
{
$link = new Link();
$product = new Product($id_product, true, $id_lang);
$category = new Category($product->id_category_default, $id_lang);
$product->objectID = $product->id;
$product->category = $category->name;
$product->url = $link->getProductLink($product->id);
/* Cover */
$cover = Image::getCover($product->id);
$product->image_link_small = $link->getImageLink($product->link_rewrite, $cover['id_image'], ImageType::getFormatedName('small'));
$product->image_link_large = $link->getImageLink($product->link_rewrite, $cover['id_image'], ImageType::getFormatedName('large'));
return $product;
}
示例3: sendCampaign
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'];
}
}
}
}
示例4: getArticles
protected function getArticles(Order $order, $cart = false)
{
$this->to_refund = 0;
$this->to_refund_tax = 0;
if ($cart) {
$products = $cart->getProducts();
} else {
$products = $order->getProducts();
foreach ($products as $key => &$order_item) {
$order_item['product_quantity'] -= $order_item['product_quantity_refunded'];
$this->to_refund += $order_item['product_quantity_refunded'] * $order_item['unit_price_tax_incl'];
$this->to_refund_tax += $order_item['product_quantity_refunded'] * $order_item['unit_price_tax_excl'];
if ((int) $order_item['product_quantity'] <= 0) {
unset($products[$key]);
}
}
}
$articles = array();
$link = new Link();
foreach ($products as $order_item) {
if ($cart) {
$productId = $order_item['id_product'];
$Product = new Product($productId);
$discounts = $order_item['reduction_applies'];
$quantity = $order_item['cart_quantity'];
$price = $order_item['price_wt'];
$description_short = strip_tags($order_item['description_short']);
$image_url = str_replace('http://', '', $link->getImageLink('product', $order_item['id_image']));
$name = $order_item['name'];
$sku = $order_item['id_product_attribute'];
$product_url = $link->getProductLink($productId);
} else {
$productId = $order_item['product_id'];
$Product = new Product($productId);
$discounts = $order_item['reduction_amount_tax_incl'];
$quantity = $order_item['product_quantity'];
$price = $order_item['unit_price_tax_incl'];
$description_short = strip_tags($order_item['description_short']);
$image_url = str_replace('http://', '', $link->getImageLink('product', $order_item['image']->id));
$name = $order_item['product_name'];
$sku = $order_item['product_attribute_id'];
$product_url = $link->getProductLink($productId);
}
$articles[] = array("id" => $productId, "sku" => $sku, "name" => $name, "description" => substr($description_short, 0, 255), "url" => $product_url, "image_url" => 'http://' . $image_url, "quantity" => intval($quantity), "price" => static::formatDecimals($price), "tax_rate" => static::formatDecimals($Product->getTaxesRate()), "discount" => static::formatDecimals($discounts));
}
return $articles;
}
示例5: getUrlsProduct
public static function getUrlsProduct($product_id)
{
$product_exist = Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'product WHERE id_product =' . (int) $product_id);
if ($product_exist) {
$o_product = new Product($product_id, false, (int) Configuration::get('PS_LANG_DEFAULT'));
$protocol_link = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://';
$use_ssl = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? true : false;
$protocol_content = $use_ssl ? 'https://' : 'http://';
$link = new Link($protocol_link, $protocol_content);
$id_cover_image = Image::getCover($product_id);
$image_path = $link->getImageLink($o_product->link_rewrite[(int) Configuration::get('PS_LANG_DEFAULT')], $id_cover_image['id_image']);
$url_product = $link->getProductLink($product_id);
return array('url_product' => $url_product, 'url_image_product' => $image_path);
}
}
示例6: generateXmlFlow
//.........这里部分代码省略.........
$product->addChild('downloadable', $sqlProduct['id_product_download'] >= 1 ? 1 : 0);
$pack = Db::getInstance()->ExecuteS('
SELECT p.id_product, pp.quantity
FROM ' . _DB_PREFIX_ . 'pack pp
LEFT JOIN ' . _DB_PREFIX_ . 'product p ON (p.id_product = pp.id_product_item)
WHERE pp.id_product_pack = ' . (int) $sqlProduct['id_product']);
if (sizeof($pack)) {
$pack = $product->addChild('pack');
foreach ($pack as $p) {
$packItem = $pack->addChild('pack-item');
$packItem->addChild('quantity', (int) $p['quantity']);
$packItem->addChild('sku', (int) $p['id_product']);
}
}
$images = Db::getInstance()->ExecuteS('
SELECT i.id_image, il.legend, l.iso_code
FROM ' . _DB_PREFIX_ . 'image i
LEFT JOIN ' . _DB_PREFIX_ . 'image_lang il ON (il.id_image = i.id_image)
LEFT JOIN ' . _DB_PREFIX_ . 'lang l ON (l.id_lang = il.id_lang)
WHERE i.id_product = ' . (int) $sqlProduct['id_product']);
$imagesLegends = array();
foreach ($images as $image) {
$imagesLegends[(int) $image['id_image']][$image['iso_code']]['legend'] = $image['legend'];
$imagesLegends[(int) $image['id_image']][$image['iso_code']]['iso_code'] = $image['iso_code'];
}
$imagesAlreadyDone = array();
foreach ($images as $imageSQL) {
if (isset($imagesAlreadyDone[$imageSQL['id_image']])) {
continue;
}
$imagesAlreadyDone[(int) $imageSQL['id_image']] = 1;
$image = $product->addChild('image');
$image->addAttribute('id', $imageSQL['id_image']);
$image->addCData('image-url', $link->getImageLink($productLinkRewrite, (int) $sqlProduct['id_product'] . '-' . (int) $imageSQL['id_image'], 'large'));
if (isset($imagesLegends[$imageSQL['id_image']]) and sizeof($imagesLegends[$imageSQL['id_image']])) {
$imageCaption = $image->addChild('image-caption');
$languageVariant = $imageCaption->addChild('language-variant');
foreach ($imagesLegends[(int) $imageSQL['id_image']] as $legend) {
$variant = $languageVariant->addChild('variant');
$variant->addChild('locale', $legend['iso_code']);
$variant->addCData('value', $legend['legend']);
}
}
}
if (version_compare(_PS_VERSION_, '1.4') < 0) {
$quantityDiscounts = Db::getInstance()->ExecuteS('
SELECT dq.quantity, dq.value, dq.id_discount_type
FROM ' . _DB_PREFIX_ . 'discount_quantity dq
WHERE dq.id_product = ' . intval($sqlProduct['id_product']));
foreach ($quantityDiscounts as $quantityDiscount) {
$discount = $product->addChild('discount');
$discount->addChild('discount-quantity', intval($quantityDiscount['quantity']));
$discount->addChild('discount-value', floatval($quantityDiscount['value']));
$discount->addChild('discount-type', $quantityDiscount['id_discount_type'] == 1 ? $defaultCurrencyIsoCode : '%');
}
} else {
$quantityDiscounts = SpecificPrice::getQuantityDiscounts((int) $sqlProduct['id_product'], (int) Shop::getCurrentShop(), 0, 0, 0);
foreach ($quantityDiscounts as $quantityDiscount) {
$discount = $product->addChild('discount');
$discount->addChild('discount-quantity', (int) $quantityDiscount['from_quantity']);
$discount->addChild('discount-value', ((double) $quantityDiscount['price'] and $quantityDiscount['reduction_type'] == 'amount') ? (double) $quantityDiscount['price'] : $quantityDiscount['reduction'] * 100);
$discount->addChild('discount-type', $quantityDiscount['reduction_type'] == 'amount' ? $defaultCurrencyIsoCode : '%');
}
}
$categories = Db::getInstance()->ExecuteS('
SELECT cl.name, l.iso_code
示例7: sendCampaign
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);
}
}
}
}
示例8: hookProductOneImg
public function hookProductOneImg($listPro)
{
$link = new Link();
$id_lang = Context::getContext()->language->id;
$where = " WHERE i.`id_product` IN (" . $listPro . ") AND ish.`cover`=0";
$order = " ORDER BY i.`id_product`,`position`";
$limit = " LIMIT 0,1";
//get product info
$listImg = $this->getAllImages($id_lang, $where, $order, $limit);
$savedImg = array();
$obj = array();
$this->smarty->assign(array('homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'smallSize' => Image::getSize(ImageType::getFormatedName('small'))));
foreach ($listImg as $product) {
if (!in_array($product["id_product"], $savedImg)) {
$obj[] = array("id" => $product["id_product"], "content" => $link->getImageLink($product['link_rewrite'], $product["id_image"], 'home' . '_default'));
}
$savedImg[] = $product["id_product"];
}
return $obj;
}
示例9: hookProductOneImg
public function hookProductOneImg($listPro)
{
$protocol_link = Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? 'https://' : 'http://';
$useSSL = isset($this->ssl) && $this->ssl && Configuration::get('PS_SSL_ENABLED') || Tools::usingSecureMode() ? true : false;
$protocol_content = $useSSL ? 'https://' : 'http://';
$link = new Link($protocol_link, $protocol_content);
$id_lang = Context::getContext()->language->id;
$where = ' WHERE i.`id_product` IN (' . $listPro . ') AND (ish.`cover`=0 OR ish.`cover` IS NULL) AND ish.`id_shop` = ' . Context::getContext()->shop->id;
$order = ' ORDER BY i.`id_product`,`position`';
$limit = ' LIMIT 0,1';
//get product info
$listImg = $this->getAllImages($id_lang, $where, $order, $limit);
$savedImg = array();
$obj = array();
$this->smarty->assign(array('homeSize' => Image::getSize(ImageType::getFormatedName('home')), 'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')), 'smallSize' => Image::getSize(ImageType::getFormatedName('small'))));
foreach ($listImg as $product) {
if (!in_array($product['id_product'], $savedImg)) {
$obj[] = array('id' => $product['id_product'], 'content' => $link->getImageLink($product['link_rewrite'], $product['id_image'], 'home' . '_default'));
}
$savedImg[] = $product['id_product'];
}
return $obj;
}
示例10: createProductObject
function createProductObject($prestaProduct, $variant, $categories, $extradata)
{
$id = $prestaProduct['id_product'];
$product = new CEProduct();
$active = filter_var($prestaProduct['active'], FILTER_VALIDATE_BOOLEAN);
$product->setDeactivate(!$active);
$product->setName($prestaProduct['name']);
$product->setDescription(strip_tags($prestaProduct['description']));
$product->setBrand($prestaProduct['manufacturer_name']);
if (isset($extradata[$id])) {
$this->setSpecs($product, $extradata[$id], false);
}
if (isset($prestaProduct['rate'])) {
$product->setVatRate($prestaProduct['rate']);
} else {
$taxObject = new Tax($prestaProduct['id_tax_rules_group'], 1);
$product->setVatRate($taxObject->rate);
}
//product data
$id_image = $prestaProduct['id_image'];
$price = $prestaProduct['price'] * (1.0 + $product->getVatRate() / 100.0);
$ed = $product->getExtraData();
$minQty = new CEProductExtraDataItem();
$minQty->setKey('MinimalOrderQuantity');
$minQty->setIsPublic(false);
if (!$variant) {
$merchantProductNo = $id;
$product->setStock($prestaProduct['quantity']);
$product->setEan($this->extractGtin($prestaProduct));
$minQty->setValue($prestaProduct['minimal_quantity']);
} else {
$merchantProductNo = $id . "-" . $variant['id_product_attribute'];
$product->setGroupNo($id);
$product->setStock($variant['quantity']);
$product->setEan($this->extractGtin($variant));
$minQty->setValue($variant['minimal_quantity']);
//add variant specific image
if (isset($variant['id_image']) && $variant['id_image']) {
$id_image = $variant['id_image'];
}
//add variant price change to default price. Using product_attribute_shop.price
if ($variant['price'] != 0) {
$price = ($prestaProduct['price'] + $variant['price']) * (1.0 + $product->getVatRate() / 100.0);
}
//loop all variant attribute_info
if (isset($variant['all_attribute_info']) && is_array($variant['all_attribute_info'])) {
$this->setSpecs($product, $variant['all_attribute_info'], true);
}
}
$ed[] = $minQty;
$product->setExtraData($ed);
$product->setMerchantProductNo($merchantProductNo);
$product->setPrice($price);
$product->setListPrice($price);
if (isset($prestaProduct['id_category'])) {
$product->setCategoryTrail($categories[$prestaProduct['id_category']]);
} else {
$category_path = $this->getProductCategories($id);
$product->setCategoryTrail($category_path);
}
$product->setShippingCost($prestaProduct['additional_shipping_cost']);
$link = new Link();
$product->setUrl($link->getProductLink($id));
$base_path = _PS_BASE_URL_ . __PS_BASE_URI__;
$base_path = preg_replace('#^https?://#', '', $base_path);
$imagePath = $id_image == "" ? $base_path . 'img/p/en-default-home_default.jpg' : $link->getImageLink($prestaProduct['link_rewrite'], $id_image, '');
$product->setImageUrl((Configuration::get("PS_SSL_ENABLED") ? 'https://' : 'http://') . $imagePath);
return $product;
}
示例11: _addSitemapNodeImage
private function _addSitemapNodeImage($xml, $product)
{
foreach ($product['images'] as $img) {
$link = new Link();
$image = $xml->addChild('image', null, 'http://www.google.com/schemas/sitemap-image/1.1');
$image->addChild('loc', $link->getImageLink($product['link_rewrite'], (int) $product['id_product'] . '-' . (int) $img['id_image']), 'http://www.google.com/schemas/sitemap-image/1.1');
$legend_image = preg_replace('/(&+)/i', '&', $img['legend_image']);
$image->addChild('caption', $legend_image, 'http://www.google.com/schemas/sitemap-image/1.1');
$image->addChild('title', $legend_image, 'http://www.google.com/schemas/sitemap-image/1.1');
}
}
示例12: generate
public function generate($to_file = true)
{
$link = new Link();
include_once 'YMarket.class.php';
//Язык по умолчанию
$id_lang = intval(Configuration::get('PS_LANG_DEFAULT'));
//Валюта по умолчанию
$curr_def = new Currency(intval(Configuration::get('PS_CURRENCY_DEFAULT')));
//создаем новый магазин
$market = new YMarket($this->_settings['y_sn'], $this->_settings['y_fn'], 'http://' . Tools::getHttpHost(false, true), $this->_settings['y_ldc']);
//Валюты
if ($this->_settings['y_cu']) {
$currencies = Currency::getCurrencies();
foreach ($currencies as $currency) {
$market->add(new yCurrency($currency['iso_code'], floatval($currency['conversion_rate'])));
}
unset($currencies);
} else {
$market->add(new yCurrency($curr_def->iso_code, floatval($curr_def->conversion_rate)));
}
//Категории
$categories = Category::getCategories($id_lang, false, false);
foreach ($categories as $category) {
$catdesc = $category['meta_title'] ? $category['meta_title'] : $category['name'];
$market->add(new yCategory($category['id_category'], $catdesc, $category['id_parent']));
}
unset($categories);
//Продукты
$products = self::getProducts($id_lang);
while ($product = Db::getInstance()->nextRow($products)) {
$tmp = new yOffer($product['id_product'], $product['name'], Product::getPriceStatic($product['id_product'], $usetax = true, NULL, $decimals = 2, $divisor = NULL, $only_reduc = false, $usereduc = true, $quantity = 1, $forceAssociatedTax = true));
$tmp->id = $product['id_product'];
$tmp->type = '';
$tmp->sales_notes = $this->_settings['y_sl'];
$tmp->url = $link->getProductLink((int) $product['id_product'], $product['link_rewrite']);
//Картинка
if ($cover = self::getCover($product['id_product'])) {
$tmp->picture = $link->getImageLink($product['link_rewrite'], $cover);
}
$tmp->currencyId = $curr_def->iso_code;
$tmp->categoryId = $product['id_category_default'];
//$tmp->vendorCode = $product['reference'];
$tmp->description = $product['description'];
if ($this->_settings['y_dl']) {
$tmp->delivery = 'true';
} else {
$tmp->delivery = 'false';
}
switch ($this->_settings['y_av']) {
case 1:
$tmp->available = $product['quantity'] == 0 ? 'false' : 'true';
break;
case 3:
$tmp->available = 'false';
break;
default:
$tmp->available = 'true';
}
//$tmp->barcode = $product['ean13'];
if (ProductDownload::getIdFromIdProduct($product['id_product'])) {
$tmp->downloadable = 'true';
}
if (!($this->_settings['y_av'] == 2 and $product['quantity'] == 0)) {
$market->add($tmp);
}
}
if ($to_file) {
$fp = fopen(dirname(__FILE__) . '/../../upload/yml.xml' . ($this->_settings['y_gz'] ? '.gz' : ''), 'w');
fwrite($fp, $market->generate(false, $this->_settings['y_gz']));
fclose($fp);
} else {
$market->generate(true, $this->_settings['y_gz']);
}
}
示例13: generateFlux
public function generateFlux()
{
if (Tools::getValue('token') == '' || Tools::getValue('token') != Configuration::get('SHOPPING_FLUX_TOKEN')) {
die('Invalid Token');
}
$titles = array(0 => 'id_produit', 1 => 'nom_produit', 2 => 'url_produit', 3 => 'url_image', 4 => 'description', 5 => 'description_courte', 6 => 'prix', 7 => 'prix_barre', 8 => 'frais_de_port', 9 => 'delaiLiv', 10 => 'marque', 11 => 'rayon', 12 => 'stock', 13 => 'qte_stock', 14 => 'EAN', 15 => 'poids', 16 => 'ecotaxe', 17 => 'TVA', 18 => 'Reference constructeur', 19 => 'Reference fournisseur');
echo implode("|", $titles) . "\r\n";
//For Shipping
$configuration = Configuration::getMultiple(array('PS_TAX_ADDRESS_TYPE', 'PS_CARRIER_DEFAULT', 'PS_COUNTRY_DEFAULT', 'PS_LANG_DEFAULT', 'PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT'));
$products = Product::getSimpleProducts($configuration['PS_LANG_DEFAULT']);
$defaultCountry = new Country($configuration['PS_COUNTRY_DEFAULT'], Configuration::get('PS_LANG_DEFAULT'));
$id_zone = (int) $defaultCountry->id_zone;
$carrier = new Carrier((int) $configuration['PS_CARRIER_DEFAULT']);
$carrierTax = Tax::getCarrierTaxRate((int) $carrier->id, (int) $this->{$configuration['PS_TAX_ADDRESS_TYPE']});
foreach ($products as $key => $produit) {
$product = new Product((int) $produit['id_product'], true, $configuration['PS_LANG_DEFAULT']);
//For links
$link = new Link();
//For images
$cover = $product->getCover($product->id);
$ids = $product->id . '-' . $cover['id_image'];
//For shipping
if ($product->getPrice(true, NULL, 2, NULL, false, true, 1) >= (double) $configuration['PS_SHIPPING_FREE_PRICE'] and (double) $configuration['PS_SHIPPING_FREE_PRICE'] > 0) {
$shipping = 0;
} elseif (isset($configuration['PS_SHIPPING_FREE_WEIGHT']) and $product->weight >= (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] and (double) $configuration['PS_SHIPPING_FREE_WEIGHT'] > 0) {
$shipping = 0;
} else {
if (isset($configuration['PS_SHIPPING_HANDLING']) and $carrier->shipping_handling) {
$shipping = (double) $configuration['PS_SHIPPING_HANDLING'];
}
if ($carrier->getShippingMethod() == Carrier::SHIPPING_METHOD_WEIGHT) {
$shipping += $carrier->getDeliveryPriceByWeight($product->weight, $id_zone);
} else {
$shipping += $carrier->getDeliveryPriceByPrice($product->getPrice(true, NULL, 2, NULL, false, true, 1), $id_zone);
}
$shipping *= 1 + $carrierTax / 100;
$shipping = (double) Tools::ps_round((double) $shipping, 2);
}
$data = array();
$data[0] = $product->id;
$data[1] = $product->name;
$data[2] = $link->getProductLink($product);
$data[3] = $link->getImageLink($product->link_rewrite, $ids, 'large');
$data[4] = $product->description;
$data[5] = $product->description_short;
$data[6] = $product->getPrice(true, NULL, 2, NULL, false, true, 1);
$data[7] = $product->getPrice(true, NULL, 2, NULL, false, false, 1);
$data[8] = $shipping;
$data[9] = $carrier->delay[2];
$data[10] = $product->manufacturer_name;
$data[11] = $product->category;
$data[12] = $product->quantity > 0 ? 'oui' : 'non';
$data[13] = $product->quantity;
$data[14] = $product->ean13;
$data[15] = $product->weight;
$data[16] = $product->ecotax;
$data[17] = $product->tax_rate;
$data[18] = $product->reference;
$data[19] = $product->supplier_reference;
foreach ($data as $key => $value) {
$data[$key] = $this->clean($value);
}
echo implode("|", $data) . "\r\n";
}
}
示例14: _syncProducts
private function _syncProducts($productsList)
{
$fees = 0;
$count = 0;
$count_success = 0;
$count_error = 0;
$tab_error = array();
$date = date('Y-m-d H:i:s');
$ebay = new eBayRequest();
$categoryDefaultCache = array();
// Get errors back
if (file_exists(dirname(__FILE__) . '/log/syncError.php')) {
global $tab_error;
include dirname(__FILE__) . '/log/syncError.php';
}
// Up the time limit
@set_time_limit(3600);
// Run the products list
foreach ($productsList as $p) {
// Product instanciation
$product = new Product((int) $p['id_product'], true, $this->id_lang);
if (!$this->isVersionOneDotFive()) {
$productQuantity = new Product((int) $p['id_product']);
$quantityProduct = $productQuantity->quantity;
} else {
$quantityProduct = $product->quantity;
}
//Fix for payment modules validating orders out of context, $link will not generate fatal error.
if (is_object($this->context->link)) {
$link = $this->context->link;
} else {
$link = new Link();
}
if (Validate::isLoadedObject($product) && $product->id_category_default > 0) {
// Load default category matched in cache
if (!isset($categoryDefaultCache[$product->id_category_default])) {
$categoryDefaultCache[$product->id_category_default] = Db::getInstance()->getRow('SELECT ec.`id_category_ref`, ec.`is_multi_sku`, ecc.`percent` FROM `' . _DB_PREFIX_ . 'ebay_category` ec LEFT JOIN `' . _DB_PREFIX_ . 'ebay_category_configuration` ecc ON (ecc.`id_ebay_category` = ec.`id_ebay_category`) WHERE ecc.`id_category` = ' . (int) $product->id_category_default);
}
if ($categoryDefaultCache[$product->id_category_default]['is_multi_sku'] != 1) {
$categoryDefaultCache[$product->id_category_default]['is_multi_sku'] = $this->findIfCategoryParentIsMultiSku($categoryDefaultCache[$product->id_category_default]['id_category_ref']);
}
// Load Pictures
$pictures = array();
$picturesMedium = array();
$picturesLarge = array();
$prefix = substr(_PS_VERSION_, 0, 3) == '1.3' ? Tools::getShopDomain(true) . '/' : '';
$images = $product->getImages($this->id_lang);
foreach ($images as $image) {
$pictures[] = str_replace('https://', 'http://', $prefix . $link->getImageLink('ebay', $product->id . '-' . $image['id_image'], 'large' . ($this->isVersionOneDotFive('>=', '1.5.1') ? '_default' : '')));
$picturesMedium[] = str_replace('https://', 'http://', $prefix . $link->getImageLink('ebay', $product->id . '-' . $image['id_image'], 'medium' . ($this->isVersionOneDotFive('>=', '1.5.1') ? '_default' : '')));
$picturesLarge[] = str_replace('https://', 'http://', $prefix . $link->getImageLink('ebay', $product->id . '-' . $image['id_image'], 'large' . ($this->isVersionOneDotFive('>=', '1.5.1') ? '_default' : '')));
}
// Load Variations
$variations = array();
$variationsList = array();
$combinations = $this->isVersionOneDotFive() ? $product->getAttributeCombinations($this->context->cookie->id_lang) : $product->getAttributeCombinaisons($this->context->cookie->id_lang);
if (isset($combinations)) {
foreach ($combinations as $c) {
$variationsList[$c['group_name']][$c['attribute_name']] = 1;
$variations[$c['id_product'] . '-' . $c['id_product_attribute']]['id_attribute'] = $c['id_product_attribute'];
$variations[$c['id_product'] . '-' . $c['id_product_attribute']]['reference'] = $c['reference'];
$variations[$c['id_product'] . '-' . $c['id_product_attribute']]['quantity'] = $c['quantity'];
$variations[$c['id_product'] . '-' . $c['id_product_attribute']]['variations'][] = array('name' => $c['group_name'], 'value' => $c['attribute_name']);
$variations[$c['id_product'] . '-' . $c['id_product_attribute']]['price_static'] = Product::getPriceStatic((int) $c['id_product'], true, (int) $c['id_product_attribute']);
$price = $variations[$c['id_product'] . '-' . $c['id_product_attribute']]['price_static'];
$price_original = $price;
if (preg_match("#[-]{0,1}[0-9]{1,2}%\$#is", $categoryDefaultCache[$product->id_category_default]['percent'])) {
if ($categoryDefaultCache[$product->id_category_default]['percent'] > 0) {
$price *= 1 + $categoryDefaultCache[$product->id_category_default]['percent'] / 100;
} else {
if ($categoryDefaultCache[$product->id_category_default]['percent'] < 0) {
$price *= 1 - $categoryDefaultCache[$product->id_category_default]['percent'] / -100;
}
}
} else {
$price += $categoryDefaultCache[$product->id_category_default]['percent'];
}
$variations[$c['id_product'] . '-' . $c['id_product_attribute']]['price'] = round($price, 2);
if ($categoryDefaultCache[$product->id_category_default]['percent'] < 0) {
$variations[$c['id_product'] . '-' . $c['id_product_attribute']]['price_original'] = round($price_original, 2);
$variations[$c['id_product'] . '-' . $c['id_product_attribute']]['price_percent'] = round($categoryDefaultCache[$product->id_category_default]['percent']);
}
}
}
// Load Variations Pictures
$combinationsImages = $product->getCombinationImages(2);
if (isset($combinationsImages) && !empty($combinationsImages) && count($combinationsImages) > 0) {
foreach ($combinationsImages as $ci) {
foreach ($ci as $i) {
$variations[$product->id . '-' . $i['id_product_attribute']]['pictures'][] = $prefix . $link->getImageLink('ebay', $product->id . '-' . $i['id_image'], 'large' . ($this->isVersionOneDotFive('>=', '1.5.1') ? '_default' : ''));
}
}
}
// Load basic price
$price = Product::getPriceStatic((int) $product->id, true);
$price_original = $price;
if (preg_match("#[-]{0,1}[0-9]{1,2}%\$#is", $categoryDefaultCache[$product->id_category_default]['percent'])) {
if ($categoryDefaultCache[$product->id_category_default]['percent'] > 0) {
$price *= 1 + $categoryDefaultCache[$product->id_category_default]['percent'] / 100;
} else {
//.........这里部分代码省略.........
示例15: generateProductsData
protected function generateProductsData()
{
$delimiter = ';';
$titles = array();
$id_lang = $this->use_lang;
$new_path = new Sampledatainstall();
$f = fopen($new_path->sendPath() . 'output/products.vsc', 'w');
foreach ($this->product_fields as $field => $array) {
$titles[] = $array['label'];
}
fputcsv($f, $titles, $delimiter, '"');
$products = Product::getProducts($id_lang, 0, 0, 'id_product', 'ASC', false, true);
foreach ($products as $product) {
$line = array();
$p = new Product($product['id_product'], true, $id_lang, 1);
foreach ($this->product_fields as $field => $array) {
$line[$field] = property_exists('Product', $field) && !is_array($p->{$field}) && !Tools::isEmpty($p->{$field}) ? $p->{$field} : '';
}
$cats = $p->getProductCategoriesFull($p->id, 1);
$cat_array = array();
foreach ($cats as $cat) {
$cat_array[] = $cat['id_category'];
}
$line['categories'] = implode(',', $cat_array);
$line['price_tex'] = $p->getPrice(false);
$line['price_tin'] = $p->getPrice(true);
$line['upc'] = $p->upc ? $p->upc : '';
$line['features'] = '';
$features = $p->getFrontFeatures($id_lang);
$position = 1;
$devider = '';
foreach ($features as $feature) {
$sql = 'SELECT `id_feature`
FROM ' . _DB_PREFIX_ . 'feature_lang
WHERE `name` = "' . pSql($feature['name']) . '"';
$sql1 = 'SELECT `id_feature_value`
FROM ' . _DB_PREFIX_ . 'feature_value_lang
WHERE `value` = "' . pSql($feature['value']) . '"';
$id_feature = Db::getInstance()->getValue($sql);
$id_feature_value = Db::getInstance()->getValue($sql1);
$line['features'] .= $devider . $id_feature . ':' . $id_feature_value . ':' . $position;
$devider = ',';
$position++;
}
$specificPrice = SpecificPrice::getSpecificPrice($p->id, 1, 0, 0, 0, 0);
$line['reduction_price'] = '';
$line['reduction_percent'] = '';
$line['reduction_from'] = '';
$line['reduction_to'] = '';
if ($specificPrice) {
if ($specificPrice['reduction_type'] == 'amount') {
$line['reduction_price'] = $specificPrice['reduction'];
} elseif ($specificPrice['reduction_type'] == 'percent') {
$line['reduction_percent'] = $specificPrice['reduction'];
}
if ($line['reduction_price'] !== '' || $line['reduction_percent'] !== '') {
$line['reduction_from'] = $specificPrice['from'];
$line['reduction_to'] = $specificPrice['to'];
}
}
$tags = $p->getTags($id_lang);
$line['tags'] = $tags;
$link = new Link();
$imagelinks = array();
$images = $p->getImages($id_lang);
foreach ($images as $image) {
$imagelink = Tools::getShopProtocol() . $link->getImageLink($p->link_rewrite, $p->id . '-' . $image['id_image']);
$this->copyConverFileName($imagelink);
$imagelinks[] = $imagelink;
}
$line['image'] = implode(',', $imagelinks);
$line['delete_existing_images'] = 0;
$line['shop'] = 1;
$warehouses = Warehouse::getWarehousesByProductId($p->id);
$line['warehouse'] = '';
if (!empty($warehouses)) {
$line['warehouse'] = implode(',', array_map("{$this->getWarehouses}", $warehouses));
}
$values = array();
$accesories = $p->getAccessories($id_lang);
if (isset($accesories) && $accesories && count($accesories)) {
foreach ($accesories as $accesorie) {
$values[] = $accesorie['id_product'];
}
}
$line['accessories'] = $values ? implode(',', $values) : '';
$values = array();
$carriers = $p->getCarriers();
if (isset($carriers) && $carriers && count($carriers)) {
foreach ($carriers as $carrier) {
$values[] = $carrier['id_carrier'];
}
}
$line['carriers'] = $values ? implode(',', $values) : '';
$values = array();
$customization_fields_ids = $p->getCustomizationFieldIds();
if (class_exists('CustomizationField') && isset($customization_fields_ids) && $customization_fields_ids && count($customization_fields_ids)) {
foreach ($customization_fields_ids as $customization_field_id) {
$cf = new CustomizationField($customization_field_id['id_customization_field'], $this->use_lang);
$values[] = $cf->id . ':' . $cf->type . ':' . $cf->required . ':' . $cf->name;
//.........这里部分代码省略.........