foreach ($products as $item) { $content = $newsletterTemplate; $tblTmp = $tblTmp2 = array(); $criteria = new CriteriaCompo(); $criteria->add(new Criteria('pm_product_id', $item->getVar('product_id'), '=')); $tblTmp = $h_myshop_productsmanu->getObjects($criteria); foreach ($tblTmp as $productManufacturer) { $tblTmp2[] = $productManufacturer->getVar('pm_manu_id'); } $manufacturers = $h_myshop_manufacturer->getObjects(new Criteria('manu_id', '(' . implode(',', $tblTmp2) . ')', 'IN'), true); $tblTmp = array(); foreach ($manufacturers as $manufacturer) { $tblTmp[] = $manufacturer->getVar('manu_commercialname') . ' ' . $manufacturer->getVar('manu_name'); } $search = array('%title%', '%category%', '%author%', '%published%', '%price%', '%money%', '%hometext%', '%fulltext%', '%discountprice%', '%link%', '%product_sku%', '%product_extraid%', '%product_width%', '%product_date%', '%product_shipping_price%', '%product_stock%', '%product_unitmeasure1%', '%product_weight%', '%product_unitmeasure2%', '%product_download_url%', '%product_length%'); $replace = array($item->getVar('product_title'), $categories[$item->getVar('product_cid')]->getVar('cat_title'), implode(', ', $tblTmp), formatTimestamp($item->getVar('product_submitted'), 's'), myshop_utils::getTTC($item->getVar('product_price'), $vats[$item->getVar('product_vat_id')]->getVar('vat_rate')), myshop_utils::getModuleOption('money_full'), $item->getVar('product_summary'), $item->getVar('product_description'), myshop_utils::getTTC($item->getVar('product_discount_price'), $vats[$item->getVar('product_vat_id')]->getVar('vat_rate')), $item->getLink(), $item->getVar('product_sku'), $item->getVar('product_extraid'), $item->getVar('product_width'), $item->getVar('product_date'), $item->getVar('product_shipping_price'), $item->getVar('product_stock'), $item->getVar('product_unitmeasure1'), $item->getVar('product_weight'), $item->getVar('product_unitmeasure2'), $item->getVar('product_download_url'), $item->getVar('product_length')); $content = str_replace($search, $replace, $content); if ($removeBr) { $content = str_replace('<br />', "\r\n", $content); } if ($removeHtml) { $content = strip_tags($content); } fwrite($fp, $content); } if (xoops_trim($footer) != '') { fwrite($fp, $footer); } fclose($fp); $newsfile = MYSHOP_NEWSLETTER_URL; echo "<a href='{$newsfile}' target='_blank'>" . _AM_MYSHOP_NEWSLETTER_READY . "</a>";
} // Related product $count = myshop_utils::getModuleOption('better_together'); $xoopsTpl->assign('better_together', $count); if ($count > 0) { $productWith = 0; // Most selled product $productWith = $h_myshop_caddy->getBestWith($product->getVar('product_id')); if ($productWith > 0) { $tmpProduct = null; $tmpProduct = $h_myshop_products->get($productWith); if (is_object($tmpProduct)) { $tmp = array(); $tmp = $tmpProduct->toArray(); $tmp['product_price_ttc'] = myshop_utils::getTTC($tmpProduct->getVar('product_price'), $tblVat[$tmpProduct->getVar('product_vat_id')]->getVar('vat_rate')); $tmp['product_discount_price_ttc'] = myshop_utils::getTTC($tmpProduct->getVar('product_discount_price'), $tblVat[$tmpProduct->getVar('product_vat_id')]->getVar('vat_rate')); $xoopsTpl->assign('bestwith', $tmp); } } } // Product vote if (myshop_utils::getModuleOption('rateproducts') == 1) { $canRate = true; if ($currentUser != 0) { $canRate = $h_myshop_votedata->hasUserAlreadyVoted($currentUser, $product->getVar('product_id')); } else { $canRate = $h_myshop_votedata->hasAnonymousAlreadyVoted('', $product->getVar('product_id')); } $xoopsTpl->assign('userCanRate', $canRate); } // Meta et CSS
} $Tpl->assign('details', $details); $tblAuthors = $tbl_tmp = $tblManufacturersPerProduct = array(); $tblAuthors = $h_myshop_productsmanu->getObjects(new Criteria('pm_product_id', '(' . implode(',', array_keys($tblProducts)) . ')', 'IN'), true); foreach ($tblAuthors as $item) { $tbl_tmp[] = $item->getVar('pm_manu_id'); $tblManufacturersPerProduct[$item->getVar('pm_product_id')][] = $item; } $tbl_tmp = array_unique($tbl_tmp); $tblAuthors = $h_myshop_manufacturer->getObjects(new Criteria('manu_id', '(' . implode(',', $tbl_tmp) . ')', 'IN'), true); foreach ($tblProducts as $item) { $tbl_tmp = array(); $tbl_tmp = $item->toArray(); $tbl_tmp['product_category'] = isset($tbl_categories[$item->getVar('product_cid')]) ? $tbl_categories[$item->getVar('product_cid')]->toArray() : null; $tbl_tmp['product_price_ttc'] = myshop_utils::getTTC($item->getVar('product_price'), $vatArray[$item->getVar('product_vat_id')]->getVar('vat_rate'), false, 's'); $tbl_tmp['product_discount_price_ttc'] = myshop_utils::getTTC($item->getVar('product_discount_price'), $vatArray[$item->getVar('product_vat_id')]->getVar('vat_rate'), false, 's'); $tbl_join = array(); foreach ($tblManufacturersPerProduct[$item->getVar('product_id')] as $author) { $auteur = $tblAuthors[$author->getVar('pm_manu_id')]; $tbl_join[] = $auteur->getVar('manu_commercialname') . ' ' . $auteur->getVar('manu_name'); } if (count($tbl_join) > 0) { $tbl_tmp['product_joined_manufacturers'] = implode(', ', $tbl_join); } $Tpl->append('products', $tbl_tmp); } } $content1 = utf8_encode($Tpl->fetch('db:myshop_pdf_catalog.html')); if (myshop_utils::getModuleOption('use_price')) { $content2 = utf8_encode($Tpl->fetch('db:myshop_purchaseorder.html')); } else {