public function initialize() { global $lC_Cache, $lC_Database, $lC_Services, $lC_Currencies, $lC_Specials, $lC_Language, $lC_Image; $this->_title_link = lc_href_link(FILENAME_PRODUCTS, 'new'); $data = array(); if ($lC_Cache->isEnabled() && BOX_WHATS_NEW_CACHE > 0 && $lC_Cache->read('box-whats_new-' . $lC_Language->getCode() . '-' . $lC_Currencies->getCode(), BOX_WHATS_NEW_CACHE)) { $data = $lC_Cache->getCache(); } else { $Qnew = $lC_Database->query('select products_id from :table_products where products_status = :products_status order by products_date_added desc limit :max_random_select_new'); $Qnew->bindTable(':table_products', TABLE_PRODUCTS); $Qnew->bindInt(':products_status', 1); $Qnew->bindInt(':max_random_select_new', BOX_WHATS_NEW_RANDOM_SELECT); $Qnew->executeRandomMulti(); if ($Qnew->numberOfRows()) { // VQMOD-hookpoint; DO NOT MODIFY OR REMOVE THE LINE BELOW $lC_Product = new lC_Product($Qnew->valueInt('products_id')); $data = $lC_Product->getData(); $data['display_price'] = $lC_Product->getPriceFormated(true); $data['display_image'] = $lC_Product->getImage(); } if ($lC_Cache->isEnabled()) { $lC_Cache->write($data); } } if (!empty($data)) { $this->_content = ''; if (empty($data['display_image']) === false) { $this->_content = '<li class="box-whats-new-image"><div class="thumbnail">' . lc_link_object(lc_href_link(FILENAME_PRODUCTS, $data['keyword']), $lC_Image->show($data['display_image'], $data['name'], 'class="box-whats-new-image-src"')) . '</div></li>'; } $this->_content .= '<li class="box-whats-new-name">' . lc_link_object(lc_href_link(FILENAME_PRODUCTS, $data['keyword']), $data['name']) . '</li>'; $this->_content .= '<li class="box-whats-new-price pricing-row">' . $data['display_price'] . '</li>'; $this->_content .= '<li class="box-whats-new-buy-now pricing-row buy-btn-div"><button onclick="window.location.href=\'' . lc_href_link(FILENAME_PRODUCTS, $data['keyword'] . '&action=cart_add') . '\'" title="" type="button">' . $lC_Language->get('button_buy_now') . '</button>'; } }
public function initialize() { global $lC_Database, $lC_Cache, $lC_Language, $lC_Currencies, $lC_Image, $current_category_id; $data = array(); if ($lC_Cache->isEnabled() && MODULE_CONTENT_NEW_PRODUCTS_CACHE > 0 && $lC_Cache->read('new_products-' . $lC_Language->getCode() . '-' . $lC_Currencies->getCode() . '-' . $current_category_id, MODULE_CONTENT_NEW_PRODUCTS_CACHE)) { $data = $lC_Cache->getCache(); } else { if ($current_category_id < 1) { $Qproducts = $lC_Database->query('select products_id from :table_products where products_status = :products_status and parent_id = :parent_id order by products_date_added desc limit :max_display_new_products'); } else { $Qproducts = $lC_Database->query('select distinct p2c.products_id from :table_products p, :table_products_to_categories p2c, :table_categories c where c.parent_id = :category_parent_id and c.categories_id = p2c.categories_id and p2c.products_id = p.products_id and p.products_status = :products_status and p.parent_id = :parent_id order by p.products_date_added desc limit :max_display_new_products'); $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES); $Qproducts->bindTable(':table_categories', TABLE_CATEGORIES); $Qproducts->bindInt(':category_parent_id', $current_category_id); } $Qproducts->bindTable(':table_products', TABLE_PRODUCTS); $Qproducts->bindInt(':products_status', 1); $Qproducts->bindInt(':parent_id', 0); $Qproducts->bindInt(':max_display_new_products', MAX_DISPLAY_PRODUCTS_NEW); $Qproducts->execute(); while ($Qproducts->next()) { // VQMOD-hookpoint; DO NOT MODIFY OR REMOVE THE LINE BELOW $lC_Product = new lC_Product($Qproducts->valueInt('products_id')); $data[$lC_Product->getID()] = $lC_Product->getData(); $data[$lC_Product->getID()]['display_price'] = $lC_Product->getPriceFormated(true); $data[$lC_Product->getID()]['display_image'] = $lC_Product->getImage(); } if ($lC_Cache->isEnabled()) { $lC_Cache->write($data); } } if (!empty($data)) { $this->_content = ''; foreach ($data as $product) { $this->_content .= '<div class="content-new-products-container">' . "\n"; $this->_content .= ' <div class="content-new-products-image">' . lc_link_object(lc_href_link(FILENAME_PRODUCTS, $product['keyword']), $lC_Image->show($product['display_image'], $product['name'], 'class="content-new-products-image-src"')) . '</div>' . "\n" . ' <div class="content-new-products-name">' . lc_link_object(lc_href_link(FILENAME_PRODUCTS, $product['keyword']), $product['name']) . '</div>' . "\n" . ' <div class="content-new-products-desc">' . (strlen(lc_clean_html($product['description'])) > 65 ? substr(lc_clean_html($product['description']), 0, 62) . '...' : lc_clean_html($product['description'])) . '</div>' . "\n" . ' <div class="content-new-products-price pricing-row">' . $product['display_price'] . '</div>' . "\n" . ' <div class="content-new-products-button pricing-row buy-btn-div"><button class="content-new-products-add-button" onclick="window.location.href=\'' . lc_href_link(FILENAME_PRODUCTS, $product['keyword'] . '&action=cart_add') . '\'" type="button">' . $lC_Language->get('new_products_button_buy_now') . '</button></div>' . "\n"; $this->_content .= '</div>' . "\n"; } } }