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; } } $line['customization_fields_ids'] = $values ? implode(',', $values) : ''; $values = array(); $attachments = $p->getAttachments($this->use_lang); if (isset($attachments) && $attachments && count($attachments)) { foreach ($attachments as $attachment) { $values[] = $attachment['id_attachment']; } } $line['attachments'] = $values ? implode(',', $values) : ''; if (!property_exists('Product', 'base_price')) { // for versions < 1.6.0.13 $line['base_price'] = !is_array($p->base_price) && !Tools::isEmpty($p->base_price) ? $p->base_price : ''; } if (!$line[$field]) { $line[$field] = ''; } fputcsv($f, $line, $delimiter, '"'); } fclose($f); }
public function __construct() { // Set variables $this->table = 'mymod_comment'; $this->className = 'MyModComment'; $this->fields_list = array('id_mymod_comment' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25), 'shop_name' => array('title' => $this->l('Shop'), 'width' => 120, 'filter_key' => 's!name'), 'firstname' => array('title' => $this->l('Firstname'), 'width' => 120), 'lastname' => array('title' => $this->l('Lastname'), 'width' => 140), 'email' => array('title' => $this->l('E-mail'), 'width' => 150), 'product_name' => array('title' => $this->l('Product'), 'width' => 100, 'filter_key' => 'pl!name'), 'grade_display' => array('title' => $this->l('Grade'), 'align' => 'right', 'width' => 80, 'filter_key' => 'a!grade'), 'comment' => array('title' => $this->l('Comment'), 'search' => false), 'date_add' => array('title' => $this->l('Date add'), 'type' => 'date')); // Set fields form for form view $this->context = Context::getContext(); $this->context->controller = $this; $this->fields_form = array('legend' => array('title' => $this->l('Add / Edit Comment'), 'image' => '../img/admin/contact.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Firstname'), 'name' => 'firstname', 'size' => 30, 'required' => true), array('type' => 'text', 'label' => $this->l('Lastname'), 'name' => 'lastname', 'size' => 30, 'required' => true), array('type' => 'text', 'label' => $this->l('E-mail'), 'name' => 'email', 'size' => 30, 'required' => true), array('type' => 'select', 'label' => $this->l('Product'), 'name' => 'id_product', 'required' => true, 'default_value' => 1, 'options' => array('query' => Product::getProducts($this->context->cookie->id_lang, 1, 1000, 'name', 'ASC'), 'id' => 'id_product', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('Grade'), 'name' => 'grade', 'size' => 30, 'required' => true, 'desc' => $this->l('Grade must be between 1 and 5')), array('type' => 'textarea', 'label' => $this->l('Comment'), 'name' => 'comment', 'cols' => 50, 'rows' => 5, 'required' => false)), 'submit' => array('title' => $this->l('Save'))); // Enable bootstrap $this->bootstrap = true; // Call of the parent constructor method parent::__construct(); // Update the SQL request of the HelperList $this->_select = "s.`name` as shop_name, pl.`name` as product_name, CONCAT(a.`grade`, '/5') as grade_display"; $this->_join = 'LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (pl.`id_product` = a.`id_product` AND pl.`id_lang` = ' . (int) $this->context->language->id . ' AND pl.`id_shop` = a.`id_shop`) LEFT JOIN `' . _DB_PREFIX_ . 'shop` s ON (s.`id_shop` = a.`id_shop`)'; // Add actions $this->addRowAction('view'); $this->addRowAction('delete'); $this->addRowAction('edit'); // Add bulk actions $this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Would you like to delete the selected items?')), 'myaction' => array('text' => $this->l('My Action'), 'confirm' => $this->l('Are you sure?'))); // Define meta and toolbar title $this->meta_title = $this->l('Comments on Product'); if (Tools::getIsset('viewmymod_comment')) { $this->meta_title = $this->l('View comment') . ' #' . Tools::getValue('id_mymod_comment'); } $this->toolbar_title[] = $this->meta_title; }
public function displayMain() { global $smarty; $products = Product::getProducts(); $smarty->assign(array('products' => $products['entitys'])); return $smarty->fetch('shop.tpl'); }
/** * Отображения списка товаров */ public function actionProducts($mark, $model, $modification) { if (Yii::app()->request->isAjaxRequest) { $data = Product::getProducts($mark, $model, $modification); $this->renderPartial('products', array('data' => $data)); Yii::app()->end(); } }
public function renderForm() { if (!($obj = $this->loadObject(true))) { return; } $products = Product::getProducts((int) $this->context->language->id, 0, 0, 'id_product', 'ASC'); foreach ($products as $product) { $productList[] = array('key' => $product['id_product'], 'name' => '(' . $product['id_product'] . ') ' . $product['name']); } $categories = Category::getSimpleCategories((int) $this->context->language->id); foreach ($categories as $category) { $categoryList[] = array('key' => $category['id_category'], 'name' => '(' . $category['id_category'] . ') ' . $category['name']); } $cmss = CMS::listCms(); foreach ($cmss as $cms) { $cmsList[] = array('key' => $cms['id_cms'], 'name' => '(' . $cms['id_cms'] . ') ' . $cms['meta_title']); } $this->fields_form = array('tinymce' => true, 'legend' => array('title' => $this->l('Slideshow'), 'image' => '../img/admin/cog.gif'), 'input' => array(array('type' => 'text', 'lang' => true, 'label' => $this->l('Name:'), 'name' => 'name', 'size' => 40), array('type' => 'text', 'label' => $this->l('Width:'), 'name' => 'width', 'size' => 10, 'desc' => $this->l('If you change the width of the it will be necessary to upload images again')), array('type' => 'text', 'label' => $this->l('Height:'), 'name' => 'height', 'size' => 10, 'desc' => $this->l('If you change the height of the it will be necessary to upload images again')), array('type' => 'select', 'label' => $this->l('Effect:'), 'name' => 'effect', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('random')), array('key' => 1, 'name' => $this->l('swirl')), array('key' => 2, 'name' => $this->l('rain')), array('key' => 3, 'name' => $this->l('straight'))), 'name' => 'name', 'id' => 'key')), array('type' => 'text', 'label' => $this->l('Squares per width:'), 'name' => 'spw', 'size' => 10, 'desc' => $this->l('large number can cause transitions problems, Example: 7')), array('type' => 'text', 'label' => $this->l('Squares per height:'), 'name' => 'sph', 'size' => 10, 'desc' => $this->l('large number can cause transitions problems, Example: 5')), array('type' => 'text', 'label' => $this->l('Delay:'), 'name' => 'delay', 'size' => 10, 'desc' => $this->l('delay between images in ms, Example: 3000')), array('type' => 'text', 'label' => $this->l('Square delay:'), 'name' => 'sDelay', 'size' => 10, 'desc' => $this->l('delay beetwen squares in ms. Example: 30')), array('type' => 'text', 'label' => $this->l('Opacity:'), 'name' => 'opacity', 'size' => 10, 'desc' => $this->l('opacity of title and navigation. Example: 0.7')), array('type' => 'text', 'label' => $this->l('Title speed:'), 'name' => 'titleSpeed', 'size' => 10, 'desc' => $this->l('speed of title appereance in ms. Example: 500')), array('type' => 'select', 'label' => $this->l('Navigation:'), 'name' => 'navigation', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Links:'), 'name' => 'links', 'desc' => $this->l('Enable links.'), 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Hover pause:'), 'name' => 'hoverpause', 'desc' => $this->l('pause on hover.'), 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Show on home:'), 'name' => 'home', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Show on all category:'), 'name' => 'showOnCat', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Categories:'), 'name' => 'categories[]', 'id' => 'categories', 'options' => array('query' => $categoryList, 'name' => 'name', 'id' => 'key'), 'multiple' => true, 'desc' => $this->l('Choose one or several category s page where the slideshow will be displayed.')), array('type' => 'select', 'label' => $this->l('Show on all product:'), 'name' => 'showOnProd', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Products:'), 'name' => 'products[]', 'id' => 'products', 'options' => array('query' => $productList, 'name' => 'name', 'id' => 'key'), 'multiple' => true, 'desc' => $this->l('Choose one or several product s page where the slideshow will be displayed.')), array('type' => 'select', 'label' => $this->l('Show on all cms page:'), 'name' => 'showOnCms', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('no')), array('key' => 1, 'name' => $this->l('yes'))), 'name' => 'name', 'id' => 'key')), array('type' => 'select', 'label' => $this->l('Cms:'), 'name' => 'cms[]', 'id' => 'cms', 'options' => array('query' => $cmsList, 'name' => 'name', 'id' => 'key'), 'multiple' => true, 'desc' => $this->l('Choose one or several cms s page where the slideshow will be displayed.')), array('type' => 'select', 'label' => $this->l('Hook:'), 'name' => 'hook', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('name' => 'displayTop'), array('name' => 'displayHome'), array('name' => 'displayLeftColumn'), array('name' => 'displayRightColumn'), array('name' => 'displayOpartSlideshowHook')), 'name' => 'name', 'id' => 'name'), 'desc' => $this->l('You must hook the module for display your slideshow on each position. Go to modules/positions menu for setup this')), array('type' => 'select', 'label' => $this->l('Statut:'), 'name' => 'active', 'cast' => 'strval', 'identifier' => 'mode', 'options' => array('query' => array(array('key' => 0, 'name' => $this->l('disable')), array('key' => 1, 'name' => $this->l('enable'))), 'name' => 'name', 'id' => 'key'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button')); if (is_numeric($obj->id)) { //products value $sql = 'SELECT id_product FROM ' . _DB_PREFIX_ . 'opartslideshow_slideshow_product WHERE id_opartslideshow_slideshow = ' . $obj->id; $array = Db::getInstance()->executeS($sql); if (count($array)) { foreach ($array as $row) { $productValues[] = $row['id_product']; } $this->fields_value['products[]'] = $productValues; } //categories value $sql = 'SELECT id_category FROM ' . _DB_PREFIX_ . 'opartslideshow_slideshow_category WHERE id_opartslideshow_slideshow = ' . $obj->id; $array = Db::getInstance()->executeS($sql); if (count($array)) { foreach ($array as $row) { $categoriesValues[] = $row['id_category']; } $this->fields_value['categories[]'] = $categoriesValues; } //cms value $sql = 'SELECT id_cms FROM ' . _DB_PREFIX_ . 'opartslideshow_slideshow_cms WHERE id_opartslideshow_slideshow = ' . $obj->id; $array = Db::getInstance()->executeS($sql); if (count($array)) { foreach ($array as $row) { $cmsValues[] = $row['id_cms']; } $this->fields_value['cms[]'] = $cmsValues; } } $html = $header = $this->context->smarty->fetch(parent::getTemplatePath() . 'header.tpl'); $html .= parent::renderForm(); return $html; }
public function initContent() { if (!$this->errors) { $lampStart = 0; $lampLimit = 5; $lampOrderBy = 'id_product'; $lampOrderWay = 'ASC'; $lampOnlyActive = true; $lampIdCategory = 42; $id_lang = (int) $this->context->language->id; $lampIdCategories = CategoryCore::getChildren($lampIdCategory, $id_lang); Product::getProducts($id_lang, $lampStart, $lampLimit, $lampOrderBy, $lampOrderWay, $lampIdCategory, $lampOnlyActive); $prod = $this->product; $this->context->smarty->assign(array('HOOK_LAMP_ACCESSORIES' => Hook::exec('lampAccessories'))); } parent::initContent(); $this->setTemplate(_PS_THEME_DIR_ . 'product.tpl'); }
/** * @return array * @throws \Exception * @author Panagiotis Vagenas <*****@*****.**> * @since 150213 */ public function createProductsArray() { $products = \Product::getProducts($this->defaultLang, 0, 0, 'id_product', 'ASC', false, $this->Options->getValue('include_disabled')); $backOrdersAvailString = $this->Options->getValue('avail_backorders'); $outOfStockAvailString = $this->Options->getValue('avail_outOfStock'); $backOrdersInclude = $this->String->is_not_empty($backOrdersAvailString); $outOfStockInclude = $this->String->is_not_empty($outOfStockAvailString); foreach ((array) $products as $key => $product) { $p = new \Product($product['id_product']); // TODO Check for product avail etc $hasStock = $p->getRealQuantity($p->id) > 0; // TODO Is this a convenient way? if ($p->getType() != 0 || $p->visibility == 'none' || $p->available_for_order == 0) { unset($products[$key]); // TODO Log skipped product continue; } if (!$hasStock) { // TODO backOrdersAllowed not working as expected if ($p->getRealQuantity($p->id) == 0 && !$outOfStockInclude) { unset($products[$key]); // TODO Log skipped product continue; } else { if ($p->getRealQuantity($p->id) < 0 && (!$backOrdersInclude || !$this->backOrdersAllowed($p))) { // quantity < 0 unset($products[$key]); // TODO Log skipped product continue; } } } $pushArray = $this->getProductArray($p); if (!empty($pushArray)) { $products[$key] = $pushArray; } else { // TODO Log skipped product unset($products[$key]); } } return $products; }
public function getProductsByCategoryAndManufacturerID() { if (!isset($_GET['id_category']) && !isset($_GET['id_manufacturer'])) { return false; } $id_category = $_GET['id_category']; $id_manufacturer = $_GET['id_manufacturer']; $delimiter = $_GET['delimiter']; $product = new Product(); $res = $product->getProducts($id_category, $id_manufacturer, $delimiter); while ($row = PDOQuery::getInstance()->next_row($res)) { // $products .= '<li class="product-list">'; // $products .= '<a max="'.$row['stock_available'].'" price='.$row['price'].' href="tools/ajax/AjaxProductsController.php?action=getProductByID&id_product='. // $row['id_product'].'">'.$row['product'].' ('.$row['stock_available'].')</a>'; // $products .= '</li>'; $products .= '{"stock_available": "' . $row['stock_available'] . '", "price": "' . $row['price'] . '", "id_product": "' . $row['id_product'] . '", "product": "' . $row['product'] . '"},'; } $products = '{"success": [' . rtrim($products, ',') . ']}'; echo $products; }
echo $_GET['filter']['tracking.hash']; ?> " placeholder="Session ID" style="width: 120px;" /> <input type="text" name="filter[users.source]" value="<?php echo $_GET['filter']['users.source']; ?> " placeholder="Source" style="width: 120px;" /> <input type="text" name="filter[tracking.cid]" value="<?php echo $_GET['filter']['tracking.cid']; ?> " placeholder="Custom ID" style="width: 120px;" /> <select name="filter[products.id]" style="width: 210px;"> <option value=""></option> <?php $p = new Product($db); $ps = $p->getProducts(); foreach ($ps as $pr) { ?> <option value="<?php echo $pr['id']; ?> " <?php if ($_GET['filter']['products.id'] == $pr['id']) { echo "selected"; } ?> ><?php echo $pr['title']; ?> </option>
function getProducts() { include_once "../model/Product.php"; $searchEntry = $_REQUEST['searchEntry']; $product = new Product(); $products = $product->getProducts($searchEntry); if (!$products) { echo '{"result": 0, "message": "No products yet"}'; return; } echo '{"result": 1, "products": ['; while ($products) { echo json_encode($products); $products = $product->fetch(); if ($products) { echo ","; } } echo ']}'; return; }
} else { throw new Exception('Invalid manufactuer id "' . $id . '" passed in'); } } $manufacturerIds = array_map(create_function('$a', 'return $a->getId();'), $manufacturers); foreach ($categoryIds as $id) { if (($i = ProductCategory::get($id)) instanceof ProductCategory) { $categories[] = $i; echo 'try to disable all product with category "' . $i->getName() . '"(' . $i->getId() . ')' . "\n"; } else { throw new Exception('Invalid category id "' . $id . '" passed in'); } } $categoryIds = array_map(create_function('$a', 'return $a->getId();'), $categories); // run $products = Product::getProducts('', '', array(), $manufacturerIds, $categoryIds); $count = 0; echo 'found total ' . count($products) . ' products' . "\n"; foreach ($products as $product) { if ($product->getStockOnHand() == 0 && $product->getStockOnOrder() == 0 && $product->getStockOnPO() == 0 && $product->getStockInParts() == 0) { $sku = $product->getSku(); disableProduct($sku); $count++; } } echo 'total ' . $count . ' products changed' . "\n"; echo "Done disableProducts from magento MELB TIME: " . UDate::now(UDate::TIME_ZONE_MELB) . "\n"; function disableProduct($sku) { $sku = trim($sku); $params = array();
<a href="<?php echo BASE_URL . '/product'; ?> " class="btn btn-default">Cancel</a> <input type="hidden" value="<?php echo $getProduct->id; ?> " id="prod_id" /> </div> </div> </div> </form> </div> <?php } else { echo '<div class="col-md-8"><h4>No Record Found</h4></div>'; } } else { $getProducts = $Products->getProducts(); if (count($getProducts)) { foreach ($getProducts as $val) { echo "<div class='col-md-6'>\n\t\t\t\t \t\t<div class='panel panel-warning'>\n\t\t\t\t\t\t<div class='panel-heading'><a href='" . BASE_URL . "/editproduct/{$val->id}'>{$val->product}</a></div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>"; } } else { echo "<h4>No Record Yet</h4>"; } } ?> </div> </div>
<?php require 'include/config.php'; require 'include/class.product.php'; $p = new Product($db); $prod = $p->getProducts(); include 'include/top.php'; ?> <table class="tablesorter"> <thead> <tr> <th>ID</th> <th>Title</th> <th>Earning</th> <th>Network Vendor ID</th> <th>Network</th> <th>Hash</th> <th>Parameter</th> <th>Auto subscribe enabled</th> <th>Auto subscribe lists</th> </tr> </thead> <tbody> <?php foreach ($prod as $pr) { ?> <tr> <td><?php echo $pr['id'];
public function getArticle($start, $limit) { $product = new Product(); $procucts = $product->getProducts($this->id_lang, $start, $limit, 'id_product', 'ASC'); return $procucts; }
$("#link").html(l); return false; } </script> <form method="post" onsubmit="return generateLink(this)"> <p> <label><span>Email placeholder syntax</span></label> <input type="text" name="syntax" id="syntax" placeholder="Email placeholder syntax" /> </p> <p> <label><span>Product to promote</span></label> <select name="product" id="product"> <?php $p = new Product($db); $pr = $p->getProducts(); foreach ($pr as $product) { ?> <option value="<?php echo $product['id'] . "|" . (substr($product['parameter'], 0, 6) != 'email=' ? $product['parameter'] : ''); ?> "><?php echo $product['title']; ?> </option> <?php } ?> </select>
public function actionDisplay($type) { $product = new Product(); $this->productList = $product->getProducts($type); $this->render("productList", array("type" => $type)); }
include dirname(__FILE__) . '/../../config/config.inc.php'; require_once dirname(__FILE__) . '/../../init.php'; // Get data $number = intval(Tools::getValue('n')) ? intval(Tools::getValue('n')) : 10; $orderByValues = array(0 => 'name', 1 => 'price', 2 => 'date_add', 3 => 'date_upd', 4 => 'position', 5 => 'manufacturer_name', 6 => 'quantity'); $orderWayValues = array(0 => 'ASC', 1 => 'DESC'); $orderBy = Tools::strtolower(Tools::getValue('orderby', $orderByValues[intval(Configuration::get('PS_PRODUCTS_ORDER_BY'))])); $orderWay = Tools::strtoupper(Tools::getValue('orderway', $orderWayValues[intval(Configuration::get('PS_PRODUCTS_ORDER_WAY'))])); if (!in_array($orderBy, $orderByValues)) { $orderBy = $orderByValues[0]; } if (!in_array($orderWay, $orderWayValues)) { $orderWay = $orderWayValues[0]; } $id_category = intval(Tools::getValue('id_category')) ? intval(Tools::getValue('id_category')) : 1; $products = Product::getProducts(intval($cookie->id_lang), 0, $number > 10 ? 10 : $number, $orderBy, $orderWay, $id_category, true); $currency = new Currency(intval($cookie->id_currency)); $affiliate = Tools::getValue('ac') ? '?ac=' . intval(Tools::getValue('ac')) : ''; // Send feed header("Content-Type:text/xml; charset=utf-8"); echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; ?> <rss version="2.0"> <channel> <title><![CDATA[<?php echo Configuration::get('PS_SHOP_NAME'); ?> ]]></title> <link><?php echo _PS_BASE_URL_ . __PS_BASE_URI__; ?>
<col width="" /> <col width="" /> <col width="" /> <col width="5px" /> <col width="5px" /> </colgroup> <thead> <tr> <th>#</th> <th>Product</th> <th>Type</th> <th>Price</th> <th>Date Created</th> <th colspan='2' class='center'>Action</th> </tr> </thead> <tbody> <?php $data = $Products->getProducts(); if (count($data)) { foreach ($data as $k => $v) { $k++; echo "\n\t\t\t\t<tr>\n\t\t\t\t<td>{$k}</td>\n\t\t\t\t<td>{$v->product}</td>\n\t\t\t\t<td>{$v->type}</td>\n\t\t\t\t<td>{$v->price}</td>\n\t\t\t\t<td>{$v->date}</td>\n\t\t\t\t<td><a href='" . BASE_URL . "/deleteproduct/{$v->id}' data-id='{$v->id}' class='btn'><i class='glyphicon glyphicon-trash'></i></a></td>\n\t\t\t\t<td><a href='" . BASE_URL . "/editproduct/{$v->id}' data-id='{$v->id}' class='btn'><i class='glyphicon glyphicon-pencil'></i></a></td>\n\t\t\t\t</tr>\n\t\t\t\t"; } } else { echo "<tr><td colspan='7' class='center'>No record yet<td></tr>"; } ?> </tbody> </table> </div>
<table class="table table-striped table-bordered table-hover" id="sample_1"> <thead> <tr> <th class="table-checkbox"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"/></th> <th>Product Name</th> <th>Category</th> <th>Model</th> <th>Unit</th> <th>Volume</th> <th>Date Created</th> <th>Action</th> </tr> </thead> <tbody> <?php $results = Product::getProducts(); if (count($results) > 0) { for ($index = 0; $index < count($results); $index++) { $rows = $results[$index]; ?> <tr class="<?php echo ($index + 1) % 2 == 0 ? 'even' : 'odd'; ?> gradeX"> <td> <input name="delete[]" type="checkbox" id="delete[]" value="<?php echo $rows['id']; ?> " class="checkboxes" /> </td> <td><?php echo $general->subStr($rows['productname'], 60); ?>
public function showAction($title = 'Main', $idCategory = 0) { parent::GetSideCategories(0); $this->tag->appendTitle(': ' . $title); $this->view->products = Product::getProducts($idCategory); }
/** * Getting the items * * @param unknown $sender * @param unknown $param * @throws Exception * */ public function getItems($sender, $param) { $results = $errors = array(); try { $class = trim($this->_focusEntity); if (!isset($param->CallbackParameter->searchCriteria) || count($serachCriteria = json_decode(json_encode($param->CallbackParameter->searchCriteria), true)) === 0) { throw new Exception('System Error: search criteria not provided!'); } $sumArray = array(); if (isset($serachCriteria['pro.id']) && ($product = Product::get($serachCriteria['pro.id'])) instanceof Product) { $objects = array($product); $stats = array('totalPages' => 1); } else { $pageNo = 1; $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE; if (isset($param->CallbackParameter->pagination)) { $pageNo = $param->CallbackParameter->pagination->pageNo; $pageSize = $param->CallbackParameter->pagination->pageSize; } $stats = array(); $serachCriteria = $this->getSearchCriteria($serachCriteria); $objects = Product::getProducts($serachCriteria->sku, $serachCriteria->name, $serachCriteria->supplierIds, $serachCriteria->manufacturerIds, $serachCriteria->categoryIds, $serachCriteria->productStatusIds, $serachCriteria->active, $pageNo, $pageSize, array('pro.name' => 'asc'), $stats, $serachCriteria->stockLevel, $sumArray, $serachCriteria->sh_from, $serachCriteria->sh_to, $serachCriteria->sellOnWeb); } $results['pageStats'] = $stats; $results['items'] = array(); foreach ($objects as $obj) { $results['items'][] = $obj->getJson(); } $results['totalStockOnHand'] = isset($sumArray['totalStockOnHand']) ? trim($sumArray['totalStockOnHand']) : 0; $results['totalOnHandValue'] = isset($sumArray['totalOnHandValue']) ? trim($sumArray['totalOnHandValue']) : 0; } catch (Exception $ex) { $errors[] = $ex->getMessage(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
public function printPDF($type, $categorie_id = 1, $products = array(), $declinaisons = array(), $unitmeasure = 'mm', $orientation = 'P', $font_size = 10, $color = '000000', $margins = array('top' => 0, 'left' => 0, 'right' => 0, 'bottom' => 0), $barheight = 80, $barwidth = 50, $blocheight = 150, $blocwidth = 100, $blockborder = 0, $dimension = 'A4', $stretch = 0, $setborder = 1, $showname = 1, $showref = 1, $showprice = 1, $nbproduct = 1000, $manufacturer_id = 0) { $usereduction = Configuration::get('JC-EANUPC-usereduction'); $font_size_barcode = $font_size; $unitmeasure == 'mm' ? $font_size *= 2.84 : ($font_size *= 1); $color = $this->hex2RGB(trim($color)); $max_length = 1000; if (Configuration::get('JC-EANUPC-truncateproductname')) { $max_length = Configuration::get('JC-EANUPC-truncateproductname'); } $allproduct = array(); if (!isset($products) || empty($products) || !$products || $products['0'] == '0') { $allproduct = Product::getProducts((int) $this->context->language->id, 0, '3000', 'id_product', 'ASC', $categorie_id); } else { if (empty($declinaisons)) { $i = 0; foreach ($products as $product) { $p = new Product($product, false, $this->context->language->id); $allproduct[$i]['id_product'] = $p->id; $allproduct[$i]['name'] = $p->name; $allproduct[$i]['price'] = Product::getPriceStatic($p->id, true, null, 6, null, false, $usereduction); $allproduct[$i]['reference'] = $p->reference; $allproduct[$i]['ean13'] = $p->ean13; $allproduct[$i]['upc'] = $p->upc; $allproduct[$i]['id_manufacturer'] = $p->id_manufacturer; $allproduct[$i]['quantity'] = Product::getQuantity($p->id); $i++; } } else { $i = 0; $comb_array = array(); foreach ($products as $product) { $p = new Product($product, $this->context->language->id); if ($p->id) { /* Build attributes combinations */ $combinations = $p->getAttributeCombinations($this->context->language->id); $groups = array(); if (is_array($combinations)) { foreach ($combinations as $k => $combination) { if (in_array($combination['id_product_attribute'], $declinaisons)) { // $price_to_convert = Tools::convertPrice($p->getPrice(true), $this->context->currency); // $price = Tools::displayPrice($price_to_convert, $this->context->currency); $comb_array[$combination['id_product_attribute']]['id_product_attribute'] = $combination['id_product_attribute']; $comb_array[$combination['id_product_attribute']]['attributes'][] = $combination['group_name'] . '-' . $combination['attribute_name']; $comb_array[$combination['id_product_attribute']]['wholesale_price'] = $combination['wholesale_price']; $comb_array[$combination['id_product_attribute']]['price'] = Product::getPriceStatic($p->id, true, $combination['id_product_attribute'], 6, null, false, $usereduction); $comb_array[$combination['id_product_attribute']]['weight'] = $combination['weight'] . Configuration::get('PS_WEIGHT_UNIT'); $comb_array[$combination['id_product_attribute']]['unit_impact'] = $combination['unit_price_impact']; $comb_array[$combination['id_product_attribute']]['reference'] = $combination['reference']; $comb_array[$combination['id_product_attribute']]['ean13'] = $combination['ean13']; $comb_array[$combination['id_product_attribute']]['quantity'] = $combination['quantity']; $comb_array[$combination['id_product_attribute']]['upc'] = $combination['upc']; $comb_array[$combination['id_product_attribute']]['product_name'] = $p->name[$this->context->language->id]; } } } } } $i = 0; foreach ($comb_array as $product) { // $p = new Product($product, false, $this->context->language->id); // $allproduct[$i]['id_product'] = $product['id_product']; $allproduct[$i]['name'] = $product['product_name'] . ' | ' . implode(',', $product['attributes']); $allproduct[$i]['price'] = $product['price']; $allproduct[$i]['reference'] = $product['reference']; $allproduct[$i]['ean13'] = $product['ean13']; $allproduct[$i]['upc'] = $product['upc']; $allproduct[$i]['quantity'] = $product['quantity']; // $allproduct[$i]['id_manufacturer'] = $p->id_manufacturer; $i++; } } } $array = array(1 => 'one', 2 => 'two', 3 => 'three'); if ($manufacturer_id != 0) { foreach ($allproduct as $key => $product) { if ($product['id_manufacturer'] != $manufacturer_id) { unset($allproduct[$key]); } } } if ($dimension == 'C76') { $custom_layout = array($blocwidth + $margins['left'] + $margins['right'], $blocheight + $barheight); $pdf = new TCPDF($orientation, $unitmeasure, $custom_layout); } else { $pdf = new TCPDF($orientation, $unitmeasure, $dimension); } $pdf->SetCreator('bqbarcodegeneration'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->SetFont('helvetica', '', $font_size); // set default font subsetting mode $pdf->setFontSubsetting(true); // set font $pdf->SetFont('freeserif', '', $font_size); $pdf->SetMargins($margins['left'], $margins['top'], $margins['right'], false); $pdf->SetHeaderMargin(0); $pdf->SetFooterMargin(0); // set auto page breaks $pdf->SetAutoPageBreak(true, $margins['bottom']); $page_width = TcpdfStatic::getPageSizeFromFormat($dimension); $nblignes = 1; if ($dimension == 'C76') { $nbcol = 1; } else { $nbcol = (int) $page_width[0] / ($blocwidth / 25.4 * 72); $nblignes = (int) $page_width[1] / ($blocheight / 25.4 * 72); } if ((int) $nbcol == 0) { $nbcol = 1; } // limit division by zero $c = 0; if ($type == 'upc') { $type2 = 'UPCA'; } else { $type2 = $type; } $htmloutput = '<table border="0" ><tr>'; foreach ($allproduct as $product) { $quantity = 0; if ($nbproduct == 0) { $quantity = $product['quantity']; } else { $quantity = $nbproduct; } if ($quantity == 0) { $quantity++; } for ($i = 0; $i < $quantity; $i++) { $barcode = $product[$type]; $pdf_params = $pdf->serializeTCPDFtagParameters(array(Tools::substr($barcode, 0, -1), $type2, '', '', $barwidth, $barheight, 0.4, array('position' => 'C', 'border' => $setborder == 2 ? true : false, 'padding' => 0, 'fitwidth' => false, 'fgcolor' => $color, 'bgcolor' => array(255, 255, 255), 'text' => true, 'font' => 'Helvetica', 'font_size' => $font_size_barcode, 'stretchtext' => $stretch, 'label' => ''), 'N')); if ($c % $nbcol == 0 && $c > 0 && $dimension != 'C76') { $htmloutput .= '</tr><tr>'; } // $currency = Currency::getCurrent(); // convert to pixel unit 1mm = 2.84 if (empty($barcode)) { $this->html .= '<div class=" error">' . $this->l('There is one or more missed code in selected type, plz regenerate missed code and try again') . '</div>'; return $this->html; } $autre = ''; if ($showname) { $autre .= ' <tr><td><div style="text-align:left;">' . Tools::truncate($product['name'], $max_length) . '</div></td></tr>'; } // if ($showprice) // $autre .= ' <tr><td><p style="text-align:left">'.$this->l('Price').': '.Tools::displayPrice(Product::getPriceStatic($product['id_product'])).'</p></td></tr>'; if ($showprice) { $autre .= ' <tr><td><p style="text-align:left">' . $this->l('Price') . ': ' . Tools::displayPrice($product['price']) . '</p></td></tr>'; } if ($showref) { $autre .= ' <tr><td><p style="text-align:left">' . $this->l('Reference') . ': ' . $product['reference'] . '</p></td></tr>'; } $htmloutput .= '<td style="' . ($blockborder == 1 ? 'border:1px dashed #555; border-right:0px solid #fff; ' : '') . ' font-size:' . $font_size . '%;margin:0;padding:0"> <table> ' . $autre . ' </table>'; $htmloutput .= '<table border="0" ><tr><td colspan=2> <tcpdf method="write1DBarcode" params="' . $pdf_params . '"/></td></tr> <tr><td style="font-size:150%"><p style="text-align:center">' . Tools::substr($barcode, 0, 1) . ' ' . wordwrap(Tools::substr($barcode, 1, 12), 4, ' ', true) . '</p></td></tr></table>'; $htmloutput .= '</td>'; $c++; if ($dimension == 'C76') { $htmloutput .= '</tr></table>'; $pdf->AddPage(); $pdf->writeHTML($htmloutput, true, 0, true, 0); $htmloutput = '<table border="0" ><tr>'; } } } $htmloutput .= '</tr></table> '; if ($dimension != 'C76') { // $pdf->SetAutoPageBreak(true, 0); $pdf->AddPage(); $pdf->writeHTML($htmloutput, true, 0, true, 0); } $filename = dirname(__FILE__) . '/pdf/' . $type . '.pdf'; //Output the document ob_clean(); $pdf->Output($filename, 'F'); header('Content-type: application/pdf; charset=utf-8'); header('Content-Disposition: inline; filename="$filename"'); header('Content-Length: ' . filesize($filename)); readfile($filename); }
<?php require_once 'header.php'; $product = new Product(); $products = $product->getProducts(); ?> <section id="cart_items"> <div class="container"> <div class="breadcrumbs"> <ol class="breadcrumb"> <li><a href="#">Home</a></li> <li class="active">Shopping Cart</li> </ol> </div> <div class="table-responsive cart_info"> <table class="table table-condensed"> <thead> <tr class="cart_menu"> <td class="image">Item</td> <td class="description"></td> <td class="price">Price</td> <td class="quantity">Quantity</td> <td></td> </tr> </thead> <tbody> <?php foreach ($products as $row) { ?> <tr> <td class="cart_product">
private static function _csv_export_products() { $lang = PS_CLI_UTILS::$LANG; //we must update the context before running getProducts() $context = Context::getContext(); $context->controller = new AdminProductsController(); $separator = ';'; $products = Product::getProducts($lang, 0, PHP_INT_MAX, 'id_product', 'ASC'); $FH = fopen('php://output', 'w'); //print a header $csvVals = array('ID', 'name', 'active', 'manufacturer', 'id_supplier', 'available_for_order', 'available_now', 'available_later', 'ean13', 'upc', 'reference', 'supplier_reference', 'width', 'height', 'depth', 'price', 'wholesale_price', 'additional_shipping_cost', 'online_only', 'id_tax_rules_group', 'ecotax', 'minimal_quantity', 'out_of_stock', 'quantity', 'condition', 'customizable', 'date_add', 'date_upd', 'available_for_order', 'visibility', 'description', 'description_short', 'meta_keywords', 'meta_description', 'meta_title', 'link_rewrite'); fputcsv($FH, $csvVals, $separator); foreach ($products as $product) { //print_r($product); $csvVals = array('ID', self::_csv_filter($product['name']), $product['active'], self::_csv_filter($product['manufacturer_name']), $product['id_supplier'], $product['available_for_order'], self::_csv_filter($product['available_now']), self::_csv_filter($product['available_later']), $product['ean13'], $product['upc'], self::_csv_filter($product['reference']), self::_csv_filter($product['supplier_reference']), $product['width'], $product['height'], $product['depth'], $product['price'], $product['wholesale_price'], $product['additional_shipping_cost'], $product['online_only'], $product['id_tax_rules_group'], $product['ecotax'], $product['minimal_quantity'], $product['out_of_stock'], $product['quantity'], $product['condition'], $product['customizable'], $product['date_add'], $product['date_upd'], $product['available_for_order'], $product['visibility'], self::_csv_filter($product['description']), self::_csv_filter($product['description_short']), self::_csv_filter($product['meta_keywords']), self::_csv_filter($product['meta_description']), self::_csv_filter($product['meta_title']), self::_csv_filter($product['link_rewrite'])); fputcsv($FH, $csvVals, $separator); } fclose($FH); }
/** * Getting the items * * @param unknown $sender * @param unknown $param * @throws Exception * */ public function getItems($sender, $param) { $results = $errors = array(); try { $class = trim($this->_focusEntity); if (!isset($param->CallbackParameter->searchCriteria) || count($serachCriteria = json_decode(json_encode($param->CallbackParameter->searchCriteria), true)) === 0) { throw new Exception('System Error: search criteria not provided!'); } if (isset($serachCriteria['pro.id']) && ($product = Product::get($serachCriteria['pro.id'])) instanceof Product) { $objects = array($product); $stats = array('totalPages' => 1); } else { $pageNo = 1; $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE; if (isset($param->CallbackParameter->pagination)) { $pageNo = $param->CallbackParameter->pagination->pageNo; $pageSize = $param->CallbackParameter->pagination->pageSize * 3; } $stats = array(); $categoryIds = !isset($serachCriteria['pro.productCategoryIds']) || is_null($serachCriteria['pro.productCategoryIds']) ? array() : $serachCriteria['pro.productCategoryIds']; $supplierIds = !isset($serachCriteria['pro.supplierIds']) || is_null($serachCriteria['pro.supplierIds']) ? array() : $serachCriteria['pro.supplierIds']; $manufacturerIds = !isset($serachCriteria['pro.manufacturerIds']) || is_null($serachCriteria['pro.manufacturerIds']) ? array() : $serachCriteria['pro.manufacturerIds']; $productStatusIds = !isset($serachCriteria['pro.productStatusIds']) || is_null($serachCriteria['pro.productStatusIds']) ? array() : $serachCriteria['pro.productStatusIds']; $objects = Product::getProducts(trim($serachCriteria['pro.sku']), trim($serachCriteria['pro.name']), $supplierIds, $manufacturerIds, $categoryIds, $productStatusIds, trim($serachCriteria['pro.active']), $pageNo, $pageSize, array('pro.name' => 'asc'), $stats); } $results['pageStats'] = $stats; $results['items'] = array(); foreach ($objects as $obj) { $results['items'][] = $obj->getJson(); } } catch (Exception $ex) { $errors[] = $ex->getMessage(); } $param->ResponseData = StringUtilsAbstract::getJson($results, $errors); }
echo "<option value='{$v->id}' data-limit='{$v->credit_limit}' data-balance='{$balance}'>{$v->first_name} {$v->last_name}</option>"; } } } ?> </select> </div> </div> <div class="form-group"> <label for="product_id" class="col-sm-2 control-label">Product</label> <div class="col-sm-10"> <select class="form-control" id="product_id"> <option>Select product</option> <?php if (count($Products->getProducts())) { foreach ($Products->getProducts() as $k => $v) { echo "<option data-price='{$v->price}' value='{$v->id}'>{$v->product}</option>"; } } ?> </select> </div> </div> <div class="form-group"> <label for="quantity" class="col-sm-2 control-label">Quantity</label> <div class="col-sm-3"> <select class="form-control" id="quantity"> <option>1</option> <option>2</option> <option>3</option>
* @author PrestaShop SA <*****@*****.**> * @copyright 2007-2014 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ include dirname(__FILE__) . '/../../config/config.inc.php'; require_once dirname(__FILE__) . '/../../init.php'; if (!Module::getInstanceByName('feeder')->active) { exit; } // Get data $number = (int) Tools::getValue('n') ? (int) Tools::getValue('n') : 10; $orderBy = Tools::getProductsOrder('by', Tools::getValue('orderby')); $orderWay = Tools::getProductsOrder('way', Tools::getValue('orderway')); $id_category = (int) Tools::getValue('id_category') ? (int) Tools::getValue('id_category') : Configuration::get('PS_HOME_CATEGORY'); $products = Product::getProducts((int) Context::getContext()->language->id, 0, $number > 10 ? 10 : $number, $orderBy, $orderWay, $id_category, true); $currency = new Currency((int) Context::getContext()->currency->id); $affiliate = Tools::getValue('ac') ? '?ac=' . (int) Tools::getValue('ac') : ''; $metas = Meta::getMetaByPage('index', (int) Context::getContext()->language->id); // Send feed header("Content-Type:text/xml; charset=utf-8"); echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; ?> <rss version="2.0"> <channel> <title><![CDATA[<?php echo Configuration::get('PS_SHOP_NAME'); ?> ]]></title> <description><![CDATA[<?php echo $metas['description'];
public function postProcess() { if (Tools::isSubmit('submitExport')) { $delimiter = Tools::getValue('export_delimiter'); $id_lang = Tools::getValue('export_language'); $id_shop = (int) $this->context->shop->id; set_time_limit(0); $fileName = 'products_' . date("Y_m_d_H_i_s") . '.csv'; header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header('Content-Description: File Transfer'); header("Content-type: text/csv"); header("Content-Disposition: attachment; filename={$fileName}"); header("Expires: 0"); header("Pragma: public"); $f = fopen('php://output', 'w'); foreach ($this->available_fields as $field => $array) { $titles[] = $array['label']; } fputcsv($f, $titles, $delimiter, '"'); $export_active = Tools::getValue('export_active') == 0 ? false : true; $export_category = Tools::getValue('export_category') == 99999 ? false : Tools::getValue('export_category'); $products = Product::getProducts($id_lang, 0, 0, 'id_product', 'ASC', $export_category, $export_active); foreach ($products as $product) { $line = array(); $p = new Product($product['id_product'], true, $id_lang, $id_shop); $p->loadStockData(); foreach ($this->available_fields as $field => $array) { if (isset($p->{$field}) && !is_array($p->{$field})) { $line[$field] = $p->{$field} ? $p->{$field} : ' '; } else { switch ($field) { case 'categories': $cats = $p->getProductCategoriesFull($p->id, $id_lang); $cat_array = array(); foreach ($cats as $cat) { $cat_array[] = $cat['name']; } $line['categories'] = implode(",", $cat_array); break; case 'price_tex': $line['price_tex'] = $p->getPrice(false); $line['price_tin'] = $p->getPrice(true); break; case 'upc': $line['upc'] = $p->upc ? $p->upc : ' '; break; case 'features': $line['features'] = ''; $features = $p->getFrontFeatures($id_lang); $position = 1; foreach ($features as $feature) { $line['features'] .= $feature['name'] . ':' . $feature['value'] . ':' . $position; $position++; } break; case 'reduction_price': $specificPrice = SpecificPrice::getSpecificPrice($p->id, $id_shop, 0, 0, 0, 0); $line['reduction_price'] = ''; $line['reduction_percent'] = ''; $line['reduction_from'] = ''; $line['reduction_to'] = ''; 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'] = date_format(date_create($specificPrice['from']), "Y-m-d"); $line['reduction_to'] = date_format(date_create($specificPrice['to']), "Y-m-d"); } break; case 'tags': $tags = $p->getTags($id_lang); $line['tags'] = $tags; break; case 'image': $link = new Link(); $imagelinks = array(); $images = $p->getImages($id_lang); foreach ($images as $image) { $imagelinks[] = Tools::getShopProtocol() . $link->getImageLink($p->link_rewrite, $p->id . '-' . $image['id_image']); } $line['image'] = implode(",", $imagelinks); break; case 'delete_existing_images': $line['delete_existing_images'] = 0; break; case 'shop': $line['shop'] = $id_shop; break; case 'warehouse': $warehouses = Warehouse::getWarehousesByProductId($p->id); $line['warehouse'] = ''; if (!empty($warehouses)) { $line['warehouse'] = implode(',', array_map("{$this->getWarehouses}", $warehouses)); } break; case 'date_added': $date = new DateTime($p->date_add); $line['date_add'] = $date->format("Y-m-d"); break; } } } if (!$line[$field]) { $line[$field] = ''; } fputcsv($f, $line, $delimiter, '"'); } fclose($f); die; } }
function getPriceList() { $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); if ($currency->iso_code == 'RUB') { $currency->iso_code = 'RUR'; } $desc_type = Configuration::get('YAMARKET_DESC_TYPE'); $link = $this->context->link; $this->ensureHttpPrefix($link); // Get products $products = Product::getProducts($this->id_lang, 0, 0, 'name', 'asc'); $xml = $this->getDocBody(); // Offers $offers = $xml->createElement("offers"); foreach ($products as $product) { // Get home category $category = $product['id_category_default']; if ($category == 1) { $temp_categories = Product::getProductCategories($product['id_product']); foreach ($temp_categories as $category) { if ($category != 1) { break; } } if ($category == 1) { continue; } } if (in_array($category, $this->excluded_cats)) { continue; } $prod_obj = new Product($product['id_product']); $crewrite = Category::getLinkRewrite($product['id_category_default'], $this->id_lang); $accessories = $this->getAccessories($product); $features = $this->getFeatures($product['id_product']); $combinations = $this->getCombinations($prod_obj, $currency); // template array $product_item = array('name' => html_entity_decode($product['name']), 'description' => html_entity_decode($product['description']), 'id_category_default' => $category, 'ean13' => $product['ean13'], 'accessories' => implode(',', $accessories), 'vendor' => $product['manufacturer_name']); if ($desc_type == 1) { $product_item['description'] = html_entity_decode($product['description_short']); } if ($this->country_of_origin_attr != '' && array_key_exists($this->country_of_origin_attr, $features)) { $product_item['country_of_origin'] = $features[$this->country_of_origin_attr]; unset($features[$this->country_of_origin_attr]); } if ($this->model_name_attr != '' && array_key_exists($this->model_name_attr, $features)) { $product_item['name'] = $features[$this->model_name_attr]; unset($features[$this->model_name_attr]); } if (!$product['available_for_order'] or !$product['active']) { continue; } if (!empty($combinations)) { foreach ($combinations as $combination) { $prod_obj->id_product_attribute = $combination['id_product_attribute']; $available_for_order = 1 <= StockAvailable::getQuantityAvailableByProduct($product['id_product'], $combination['id_product_attribute']); if (!$available_for_order && !$prod_obj->checkQty(1)) { continue; } $params = $this->getParams($combination); $pictures = array(); foreach ($combination['id_images'] as $id_image) { $pictures[] = $link->getImageLink($product['link_rewrite'], $product['id_product'] . '-' . $id_image, $this->image_type); } $mainPicture = array_shift($pictures); $url = $link->getProductLink($prod_obj, $product['link_rewrite'], $crewrite, null, null, null, $combination['id_product_attribute']); $extra_product_item = array('id_product' => $product['id_product'] . 'c' . $combination['id_product_attribute'], 'available_for_order' => $available_for_order, 'price' => $prod_obj->getPrice(true, $combination['id_product_attribute']), 'pictures' => $pictures, 'main_picture' => $mainPicture, 'params' => array_merge($params, $features), 'url' => $url); $offer = array_merge($product_item, $extra_product_item); $offers->appendChild($this->getOfferElem($offer, $xml, $currency)); } } else { $pictures = $this->getPictures($product['id_product'], $product['link_rewrite']); $mainPicture = array_shift($pictures); $available_for_order = 1 <= StockAvailable::getQuantityAvailableByProduct($product['id_product'], 0); if (!$available_for_order && !$prod_obj->checkQty(1)) { continue; } $url = $link->getProductLink($prod_obj, $product['link_rewrite'], $crewrite); $extra_product_item = array('id_product' => $product['id_product'], 'available_for_order' => $available_for_order, 'price' => $prod_obj->getPrice(), 'pictures' => $pictures, 'main_picture' => $mainPicture, 'params' => $features, 'url' => $url); $offer = array_merge($product_item, $extra_product_item); $offers->appendChild($this->getOfferElem($offer, $xml, $currency)); } $prod_obj->clearCache(true); } $shop = $xml->getElementsByTagName("shop")->item(0); $shop->appendChild($offers); return $xml->saveXML(); }
private function getProductsDB() { $result = array(); $products_db = Product::getProducts($this->getLang(), 0, 0, 'id_product', 'ASC'); foreach ($products_db as $value) { $result[$value['id_category_default']][] = $value; } return $result; }