Jump to content

Aioras

Members
  • Posts

    22
  • Joined

  • Last visited

Profile Information

  • Location
    Spain
  • Activity
    Developer

Aioras's Achievements

Newbie

Newbie (1/14)

4

Reputation

  1. I've override the CmsController with the changes but, can anybody help me with an example of how to create the form in the cms? for example.. what to put in the <form action= ? > etc ok, I got it, I was doing something wrong in the cms.tpl now it's showing the form but it doesn't send any email - is like if there were no connection between .tpl and the controller :/ The connection was ok, but deggugin i've seen that $id_contact for sending email is null.. so I will try to give a solution for that thanks in advance!
  2. Got it, I modified the function with One I saw on another post, this one will show every category the product is in, and not only the default one: //Created to show bestsellers products on each category @Cn static public function getBestSalesLightCat ($id_lang, $page_number = 0, $nb_products = 10, $id_category = 0, Context $context = null) { if (!$context) $context = Context::getContext(); if ($page_number < 0) $page_number = 0; if ($nb_products < 1) $nb_products = 10; $sql_groups = ''; if (Group::isFeatureActive()) { $groups = FrontController::getCurrentCustomerGroups(); $sql_groups = 'AND cg.`id_group` '.(count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); } //Subquery: get product ids in a separate query to (greatly!) improve performances and RAM usage $products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_product` cp LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`) WHERE cg.`id_group` '.$sql_groups.' AND cp.id_category = '.(int)Tools::getValue('id_category')); $ids = array(); foreach ($products as $product) $ids[$product['id_product']] = 1; $ids = array_keys($ids); sort($ids); $ids = count($ids) > 0 ? implode(',', $ids) : 'NULL'; //Main query $sql = ' SELECT p.id_product, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, pl.`link_rewrite`, pl.`name`, pl.`description_short`, product_shop.`id_category_default`, MAX(image_shop.`id_image`) id_image, il.`legend`, ps.`quantity` AS sales, p.`ean13`, p.`upc`, cl.`link_rewrite` AS category, p.show_price, p.available_for_order, IFNULL(stock.quantity, 0) as quantity, p.customizable, IFNULL(pa.minimal_quantity, p.minimal_quantity) as minimal_quantity, stock.out_of_stock, product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'" as new, product_shop.`on_sale` FROM `'._DB_PREFIX_.'product_sale` ps LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product` '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product`) '.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1').' '.Product::sqlStock('p', 'product_attribute_shop', false, $context->shop).' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').' LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'. Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').' LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON cl.`id_category` = product_shop.`id_category_default` AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl').' WHERE product_shop.`active` = 1 AND p.`visibility` != \'none\' AND p.`id_product` IN ('.$ids.') GROUP BY product_shop.id_product ORDER BY sales DESC LIMIT '.(int)($page_number * $nb_products).', '.(int)$nb_products; if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql)) return false; return Product::getProductsProperties($id_lang, $result); } got it from: https://www.prestashop.com/forums/topic/244387-show-best-sellers-products-by-category-in-product-listing-page/?p=1936215 thank ynocquet !
  3. This was my solution for 1.6.0.14 was this one: I created a new function in classes/productSale.php static public function getBestSalesLightCat ($id_lang, $pageNumber = 0, $nbProducts = 10, $id_category = 0) { global $link, $cookie; $context = Context::getContext(); if ($pageNumber < 0) $pageNumber = 0; if ($nbProducts < 1) $nbProducts = 10; $sql = ' SELECT p.id_product, MAX(product_attribute_shop.id_product_attribute) id_product_attribute, pl.`link_rewrite`, pl.`name`, pl.`description_short`, product_shop.`id_category_default`, MAX(image_shop.`id_image`) id_image, il.`legend`, ps.`quantity` AS sales, p.`ean13`, p.`upc`, cl.`link_rewrite` AS category, p.show_price, p.available_for_order, IFNULL(stock.quantity, 0) as quantity, p.customizable, IFNULL(pa.minimal_quantity, p.minimal_quantity) as minimal_quantity, stock.out_of_stock, product_shop.`date_add` > "'.date('Y-m-d', strtotime('-'.(Configuration::get('PS_NB_DAYS_NEW_PRODUCT') ? (int)Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY')).'" as new, product_shop.`on_sale`, MAX(product_attribute_shop.minimal_quantity) AS product_attribute_minimal_quantity FROM `'._DB_PREFIX_.'product_sale` ps LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product` '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (p.`id_product` = pa.`id_product`) '.Shop::addSqlAssociation('product_attribute', 'pa', false, 'product_attribute_shop.`default_on` = 1').' '.Product::sqlStock('p', 'product_attribute_shop', false, $context->shop).' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').' LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product`)'. Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').' LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.') LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON cl.`id_category` = product_shop.`id_category_default` AND cl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('cl'); if (Group::isFeatureActive()) { $groups = FrontController::getCurrentCustomerGroups(); $sql .= ' JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`) JOIN `'._DB_PREFIX_.'category_group` cg ON (cp.id_category = cg.id_category AND cg.`id_group` '.(count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1').')'; } $sql.= ' WHERE p.`active` = 1' . ($id_category == 0 ? '' : ' AND p.`id_category_default` = '.$id_category) . ' AND p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` '.(!$cookie->id_customer ? '= 1' : 'IN (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.intval($cookie->id_customer).')').') GROUP BY p.`id_product` ORDER BY sales DESC LIMIT '.intval($pageNumber * $nbProducts).', '.intval($nbProducts); if (!$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql)) return false; return Product::getProductsProperties($id_lang, $result); } and then in the call function of blockbestsellers.php: protected function getBestSellers($params) { if (Configuration::get('PS_CATALOG_MODE')) return false; $id_category = 0; if (isset($_GET['id_category']) AND intval($_GET['id_category']) > 0) { $category = new Category(intval($_GET['id_category']), intval($params['cookie']->id_lang)); if (Validate::isLoadedObject($category)) { $id_category = intval($_GET['id_category']); } if (!($result = ProductSale::getBestSalesLightCat((int)$params['cookie']->id_lang, 0, 5, $id_category))) return (Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY') ? array() : false); } else { if (!($result = ProductSale::getBestSalesLight((int)$params['cookie']->id_lang, 0, (int)Configuration::get('PS_BLOCK_BESTSELLERS_TO_DISPLAY')))) return (Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY') ? array() : false); } $currency = new Currency($params['cookie']->id_currency); $usetax = (Product::getTaxCalculationMethod((int)$this->context->customer->id) != PS_TAX_EXC); foreach ($result as &$row) $row['price'] = Tools::displayPrice(Product::getPriceStatic((int)$row['id_product'], $usetax), $currency); return $result; } which will show you category bestsellers if you are inside a category with products that have that default category or if you are outside category pages will show you the normal result hole shop bestsales Good Luck I'm trying to get the childrens inside that category also, for example: If I'm on category bikes i would like that the module shows also the products with de default category in Bikes > Mountain bikes for example If anyone have the answer plz, if get it I would post in here. reggards
  4. You just create an attribute for all the products in that category and you filter by attribute, it will show all the category products in the list
  5. you just need to install it and navigate to any search page (search for a product) and on the search result page, at the bottom of the leftColumn hook should appear, you just need to install it
  6. trying to add functionallities to this module like filter by attributes so I can have a block layered on search results and manufacturer list anybody else with this ?¿
  7. Did you solve it ? I'm doing a module and I'm stuck on that part :/
  8. Hello everybody! I'm finishing a module to add a special tax for clients, but I'm having one issue and is that I can show the added tax in the shopping cart because I added a hook on shopping-cart.tpl, to show the tax quantity and that's ok. The problem appears when I try to add that tax to the total_price variable on the shopping cart, because that's not on my module and I can't access the module variable value... My question is if it's posible to create a variable that could be accessed from shopping-cart.tpl so I could check: {if $useCustomTax} {displayPrice price=$total_price+$customTaxQuantity} {/if} for example.. And update total_cart price Any other suggestion is welcome! Reggards ***EDITED*** For now I'd discover in Cart.php this function: getSummaryDetails() in wich I can set the smarty values for the template so I will try to override cart.php file to add one variable with my $useCustomTax and my $customTaxQuantity .. and let see if it works! then I would include those overrides in my module folder, hope it works!
  9. ok... And anybody knows how to display customer database values on Cart ? because {$customer->whatever} isn't working I also added this function to the Customer.php (override) public static function hasEquivalenceSurcharge ($id_customer) { $sql = 'SELECT `recargoequivalencia` FROM `'._DB_PREFIX_.'customer` WHERE `id_customer` = '.(int)$id_customer; $recargoequivalencia = Db::getInstance()->ExecuteS($sql); return $recargoequivalencia; } and then in the AdminCustomerController.php (override) this one: public function checkEquivalenceSurcharge() { $recargoequivalencia = Customer::hasEquivalenceSurcharge($this->context->customer->id); return $this->context->smarty->assign('recargoequivalencia', $recargoequivalencia); } Just to see if I could create a "global" var but I think this is wrong because shouldn't be in the admincontroller... but I've no more imagination T.T Finally I got it creating a new override in Cart.php: In function: public function getSummaryDetails($id_lang = null, $refresh = false) at the end you have: return array( 'delivery' => $delivery, 'delivery_state' => State::getNameById($delivery->id_state), 'invoice' => $invoice, 'invoice_state' => State::getNameById($invoice->id_state), 'formattedAddresses' => $formatted_addresses, 'products' => array_values($products), 'gift_products' => $gift_products, 'discounts' => array_values($cart_rules), 'is_virtual_cart' => (int)$this->isVirtualCart(), 'total_discounts' => $total_discounts, 'total_discounts_tax_exc' => $total_discounts_tax_exc, 'total_wrapping' => $this->getOrderTotal(true, Cart::ONLY_WRAPPING), 'total_wrapping_tax_exc' => $this->getOrderTotal(false, Cart::ONLY_WRAPPING), 'total_shipping' => $total_shipping, 'total_shipping_tax_exc' => $total_shipping_tax_exc, 'total_products_wt' => $total_products_wt, 'total_products' => $total_products, 'total_price' => $base_total_tax_inc, 'total_tax' => $total_tax, 'total_price_without_tax' => $base_total_tax_exc, 'is_multi_address_delivery' => $this->isMultiAddressDelivery() || ((int)Tools::getValue('multi-shipping') == 1), 'free_ship' => $total_shipping ? 0 : 1, 'carrier' => new Carrier($this->id_carrier, $id_lang), ); Those are variables that can be called from cart controller, so I added 2 more variables and set them like: return array( 'delivery' => $delivery, 'delivery_state' => State::getNameById($delivery->id_state), 'invoice' => $invoice, 'invoice_state' => State::getNameById($invoice->id_state), 'formattedAddresses' => $formatted_addresses, 'products' => array_values($products), 'gift_products' => $gift_products, 'discounts' => array_values($cart_rules), 'is_virtual_cart' => (int)$this->isVirtualCart(), 'total_discounts' => $total_discounts, 'total_discounts_tax_exc' => $total_discounts_tax_exc, 'total_wrapping' => $this->getOrderTotal(true, Cart::ONLY_WRAPPING), 'total_wrapping_tax_exc' => $this->getOrderTotal(false, Cart::ONLY_WRAPPING), 'total_shipping' => $total_shipping, 'total_shipping_tax_exc' => $total_shipping_tax_exc, 'total_products_wt' => $total_products_wt, 'total_products' => $total_products, 'total_price' => $base_total_tax_inc, 'total_tax' => $total_tax, 'total_price_without_tax' => $base_total_tax_exc, 'is_multi_address_delivery' => $this->isMultiAddressDelivery() || ((int)Tools::getValue('multi-shipping') == 1), 'free_ship' => $total_shipping ? 0 : 1, 'carrier' => new Carrier($this->id_carrier, $id_lang), 'hasrecargoequivalencia' => (bool)RecargoEquivalencia::hasRecargoEquivalencia($this->id_customer), 'cantidadrecargo' => ((float)RecargoEquivalencia::getRecargoEquivalencia()/100), ); Those variables are set in the module function and that way I can call them from shopping-cart.tpl and the are shown! BUT... I have a new incidence.... when I try to change the product quantity from the cart sumary, I get this error: TECHNICAL ERROR: unable to save update quantity Details: Error thrown: [object Object] Text status: parsererror *****EDITED******* It fixed by disabling and enabling module ********************** I imagin that's because there is once function called on cartUpdate that I will have to look for.. Does somebody know which functions I should update for the cart quantity update?? *******EDITED******** I'm trying to edit cart-summary.js Is there any way of getting the smarty variable into the cart-summary.js ? I'd seen on internet that you can get it by doing: var quantityrecargo = {$cantidadrecargo}; but that isn't working on the .js ************************ Thanks in advance!
  10. But the point is that I would like to show them on a tpl file for example in the shopping cart I have tried this for example in category.tpl just to debug: Thanks for the answer, but the point is that I would like to check that value from the tpl file to do something like: {if isset ($customer->recargoequivalencia)} **apply special tax** {/if} what would be the best way for doing ?
  11. Hi everybody! Well I'm trying to develop a functionality in which you can set from the admin panel a especial tax for some clients. Thing I have done: Created a database column to store if client needs special tax Created a backed button on the backend edit customer Things I want to do but I'm stuck: Retrieve customer database value which is a boolean to know if special tax is active on that client Would be nice to have a field also in which you can set the special tax (would be the same value for every client with special tax) Files Edited: Override on class customer for the new field class Customer extends CustomerCore { public $recargoequivalencia = 0; public function __construct($id = null) { self::$definition['fields']['recargoequivalencia'] = array('type' => self::TYPE_BOOL, 'validate' => 'isBool'); parent::__construct($id); } } ?> Override In customer controller: Added field: elseif (Tools::isSubmit('changeRecargoequivalenciaVal') && $this->id_object) { if ($this->tabAccess['edit'] === '1') $this->action = 'change_recargoequivalencia_val'; else $this->errors[] = Tools::displayError('You do not have permission to edit this.'); } also modified the render form! for now the value on the database is working fine! But don't know how to retrieve that field! Thanks in advance!
  12. Me ocurre lo mismo, cada vez que voy a actualizar un modulo me sale el mensaje: Module xxxxx can't be upgraded: Error on downloading the latest version. Alguien sabe por qué puede ser ?!
  13. http://stackoverflow.com/questions/15978766/prestashop-1-5-3-1-free-shipping Tested and works, just set up your own id_carrier! good luck!
  14. Is not the same if you select a product as download product and there is no charge for shipping?
×
×
  • Create New...