Jump to content

hootersam

Members
  • Posts

    20
  • Joined

  • Last visited

Recent Profile Visitors

3,038,844 profile views

hootersam's Achievements

Newbie

Newbie (1/14)

9

Reputation

  1. SIMPLE WORKING SOLUTION FOR PRESTASHOP 1.6.x.x Modification adjusted to PS 1.6.x.x (tested on 1.6.1.5) for hiding categories and / or subcategories if there are no products in them. Based on solution from first page, but more elegant - using internal PS category class instead of SQL query. Open file: /modules/blockcategories/blockcategories.php Find getTree function, it should look similar to this: public function getTree($resultParents, $resultIds, $maxDepth, $id_category = null, $currentDepth = 0) { if (is_null($id_category)) $id_category = $this->context->shop->getCategory(); $children = array(); if (isset($resultParents[$id_category]) && count($resultParents[$id_category]) && ($maxDepth == 0 || $currentDepth < $maxDepth)) foreach ($resultParents[$id_category] as $subcat) $children[] = $this->getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1); if (isset($resultIds[$id_category])) { $link = $this->context->link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']); $name = $resultIds[$id_category]['name']; $desc = $resultIds[$id_category]['description']; } else $link = $name = $desc = ''; $return = array( 'id' => $id_category, 'link' => $link, 'name' => $name, 'desc'=> $desc, 'children' => $children ); return $return; } Add new lines from below or just replace whole function with this one: public function getTree($resultParents, $resultIds, $maxDepth, $id_category = null, $currentDepth = 0) { if (is_null($id_category)) $id_category = $this->context->shop->getCategory(); $children = array(); if (isset($resultParents[$id_category]) && count($resultParents[$id_category]) && ($maxDepth == 0 || $currentDepth < $maxDepth)) foreach ($resultParents[$id_category] as $subcat) $children[] = $this->getTree($resultParents, $resultIds, $maxDepth, $subcat['id_category'], $currentDepth + 1); if (isset($resultIds[$id_category])) { $link = $this->context->link->getCategoryLink($id_category, $resultIds[$id_category]['link_rewrite']); $name = $resultIds[$id_category]['name']; $desc = $resultIds[$id_category]['description']; } else $link = $name = $desc = ''; /* new 2 lines to add below */ $CategoryObj = new Category($id_category,$this->context->language->id,$this->context->shop->id); $ProductsCount = $CategoryObj->getProducts($this->context->language->id,1,1000,null,null,true,true,false,1,false,$this->context); $return = array( 'id' => $id_category, 'link' => $link, 'name' => $name, 'desc'=> $desc, 'products' => $ProductsCount, // new line to add 'children' => $children ); return $return; } Open file (if you are not using default theme your path will be different in place where it says "default-bootstrap") themes/default-bootstrap/modules/blockcategories/category-tree-branch.tpl Replace all contents in this file with this below (there are only added 2 lines - first and last, and one additional condition at line 7) {if $node.products > 0} <li {if isset($last) && $last == 'true'}class="last"{/if}> <a href="{$node.link|escape:'html':'UTF-8'}"{if isset($currentCategoryId) && $node.id == $currentCategoryId} class="selected"{/if} title="{$node.desc|strip_tags|trim|escape:'html':'UTF-8'}"> {$node.name|escape:'html':'UTF-8'} </a> {if $node.children|@count > 0 && $node.products > 0} <ul> {foreach from=$node.children item=child name=categoryTreeBranch} {if $smarty.foreach.categoryTreeBranch.last} {include file="$branche_tpl_path" node=$child last='true'} {else} {include file="$branche_tpl_path" node=$child last='false'} {/if} {/foreach} </ul> {/if} </li> {/if} Save, refresh, done. Remember when you update block categories module those modifications in your php file will be overwriten. Simply don't update block categories module or reapply solution after each update. Hope this helps someone.
  2. I agree, that statistics shouldn't be dependent on fact that prestashop invoice being created. Its just design flaw. I had same problem, because I am not using built-in invoice system (as 80% of prestashop users, I guess), so I had to find some working solution for the long run, that persists even after upgrades. You need just to override AdminStatsController.php in such way that it will take date_add instead of invoice_date. 100% working solution step by step is included in this post: https://www.prestashop.com/forums/topic/367885-dashboard-stats-are-empty-after-upgrading-to-1609/?p=2151011 And remember to delete /cache/class_index.php after creating this override. That fix is cheking stats based on order add date and not invoice date. Works fine on Prestashop 1.6.1.x with invoice disabled (with enabled invoice its working also).
  3. Thanks a lot for this simple fix for those not using prestashop invoice system. Working great on 1.6.1.2!
  4. It's 1.5.6.1 PS compatible. Didn't tested this on 1.6. It not require another modifications outside module, everything is inside this package. As i said it was some time ago i was writing this, project was cancelled and i end up with this, but this module was actually finished. It was working with custom template - maybe that is the case. Sorry but can't help you more with that :/
  5. Hi there. It was some time ago, but i found module that i was modyfing to do that. Simply installing it should do the job. Template which should be viewed on product page (hookdisplayProductTab) is extramanufacturer.tpl - there are all variables carrying wanted information. Changes that i made in code written in this post you can find in extramanufacturer.php starting at line 215. Template file has hardcoded polish language words so you have to clean this for yourself and modify template to match your site look. Hope it helps extramanufacturer.zip
  6. I found it. ProductSupplier.php /** * For a given product and supplier, gets the product supplier unit price * * @param int $id_product * @param int $id_product_attribute * @param int $id_supplier * @param bool $with_currency Optional * @return array */ public static function getProductSupplierPrice($id_product, $id_product_attribute, $id_supplier, $with_currency = false) { // build query $query = new DbQuery(); $query->select('ps.product_supplier_price_te'); if ($with_currency) $query->select('ps.id_currency'); $query->from('product_supplier', 'ps'); $query->where('ps.id_product = '.(int)$id_product.' AND ps.id_product_attribute = '.(int)$id_product_attribute.' AND ps.id_supplier = '.(int)$id_supplier ); if (!$with_currency) return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query); $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); if (isset($res[0])) return $res[0]; return $res; }
  7. Any help on this please? What is the use of supplier price for product anyway? There has to be some method that reads it from database. Please show me which object type owns that method. Is there any classes/methods full documentation for prestashop 1.5.6.1 ?
  8. I associated 3 suppliers with one product. Then I associated supplier prices for that product under Product->Suppliers tab, so each supplier has its own different price. My question is: what method should I use to get price of supplier for that product by supplier id? Is there any method like GetSupplierPriceById(product_id,supplier_id) ? I just want to have all prices available at front office on product page. I'm already passing all suppliers information, but i just noticed that prices aren't there. So i guess its different object than Suppliers. I'm on Prestashop 1.5.6.1. Thanks in advance. Edit: Just to be clear, i just want to display those supplier prices. It has not to do with real product price adding to cart etc.
  9. I figured it out form another topic, here is working code: foreach($result as $key=>&$supplier) { $id_address = Address::getAddressIdBySupplierId($supplier->id_supplier); if ($id_address > 0) { $address = new Address((int)$id_address); } $supplier_object = new Supplier($supplier->id_supplier, $this->context->language->id); $supplier = $supplier_object; $supplier->address = $address; } You have to assgin smarty $result variable. Then on product page you get: Smarty_Variable Object (3) ->value = Array (2) 0 => Supplier Object (13) ->id = 1 ->id_supplier = "1" ->name = "AppleStore" ->description = "<p>Test description</p>" ->date_add = "2013-11-27 13:45:04" ->date_upd = "2013-12-12 14:41:35" ->link_rewrite = "applestore" ->meta_title = "Meta title test" ->meta_keywords = "" ->meta_description = "Desc meta" ->active = "1" ->id_shop_list = null ->address = Address Object (25) ->id_customer = "0" ->id_manufacturer = "0" ->id_supplier = "1" ->id_warehouse = "0" ->id_country = "21" ->id_state = "32" ->country = " Stany Zjednoczone" ->alias = "AppleStore" ->company = "Apple" ->lastname = "supplier" ->firstname = "supplier" ->address1 = "767 Fifth Ave." ->address2 = "http://testurl.com" ->postcode = "10153" ->city = "New York" ->other = "" ->phone = "(212) 336-1440" ->phone_mobile = "" ->vat_number = "" ->dni = "" ->date_add = "2013-11-27 13:45:04" ->date_upd = "2013-12-12 14:39:45" ->deleted = "0" ->id = 3 ->id_shop_list = null 1 => Supplier Object (13) ->id = 2 ->id_supplier = "2" ->name = "Shure Online Store" ->description = null ->date_add = "2013-11-27 13:45:04" ->date_upd = "2013-11-27 13:45:04" ->link_rewrite = "shure-online-store" ->meta_title = null ->meta_keywords = null ->meta_description = null ->active = "1" ->id_shop_list = null ->address = Address Object (25) ->id_customer = "0" ->id_manufacturer = "0" ->id_supplier = "2" ->id_warehouse = "0" ->id_country = "21" ->id_state = "13" ->country = " Stany Zjednoczone" ->alias = "supplier" ->company = "Shure" ->lastname = "supplier" ->firstname = "supplier" ->address1 = "5800 W. Touhy Ave" ->address2 = null ->postcode = "60714" ->city = "Niles" ->other = null ->phone = "800-434-3350" ->phone_mobile = null ->vat_number = null ->dni = null ->date_add = "2013-11-27 13:45:04" ->date_upd = "2013-11-27 13:45:04" ->deleted = "0" ->id = 4 ->id_shop_list = null ->nocache = false ->scope = "Smarty root" Which is exactly what i wanted to achieve Marking as solved and thanks for help!
  10. Thanks again for pointing out that function. But Supplier object actually not contain all information, it lacks od address, addrsss2, telephone etc: My code to grab suppliers and assign them to variable: $product_all_suppliers = ProductSupplier::getSupplierCollection($id_product, true); $result = $product_all_suppliers->getResults(); foreach($result as $key=>&$supplier) { $supplier_object = new Supplier($supplier->id_supplier, $this->context->language->id); $supplier = $supplier_object; } Nad what i get in product page is: Smarty_Variable Object (3) ->value = Array (2) 0 => Supplier Object (12) ->id = 1 ->id_supplier = "1" ->name = "AppleStore" ->description = "<p>Test description</p>" ->date_add = "2013-11-27 13:45:04" ->date_upd = "2013-12-12 14:41:35" ->link_rewrite = "applestore" ->meta_title = "Meta title test" ->meta_keywords = "" ->meta_description = "Desc meta" ->active = "1" ->id_shop_list = null 1 => Supplier Object (12) ->id = 2 ->id_supplier = "2" ->name = "Shure Online Store" ->description = null ->date_add = "2013-11-27 13:45:04" ->date_upd = "2013-11-27 13:45:04" ->link_rewrite = "shure-online-store" ->meta_title = null ->meta_keywords = null ->meta_description = null ->active = "1" ->id_shop_list = null ->nocache = false ->scope = "Smarty root" So what more function should i use to get all information in that supplier object before i assgin to smarty variable? And one more question: Is this ok to create object in foreach loop every time it passes? That will not cause some kind of memory leakage server side? Or desctructor does all the job?
  11. One more question because can't find the method: How i can get all supplier information (address, description, telephone etc.) by id_supplier? Can you point me that function? Thanks!
  12. Thanks a lot for this reply! It looks like its that what i'm looking for, but it returns Collection Object and i have no idea how i can handle it. In my module i am calling this function: $product_all_suppliers = ProductSupplier::getSupplierCollection($id_product, true);$smarty->assign(array('product_all_suppliers' => $product_all_suppliers)); And i get on product page: $product_all_suppliers Smarty_Variable Object (3) ->value = Collection Object (0) ->nocache = false ->scope = "Smarty root" I dont see any sub arrays in it or something. Can you help with that? edit: Of course i had to use getResults method $suppliers_table = $product_all_suppliers->getResults(); Now everything is fine :]
  13. Ok so i analized Supplier class (classes/Supplier.php), and there is no such function which returns list of suppliers by given product_id. I found this function most close to what i want ot achieve: public static function getSuppliers($get_nb_products = false, $id_lang = 0, $active = true, $p = false, $n = false, $all_groups = false) It returns all suppliers with number of products associated with them optionally. So i guess i have to add new argument to that function like "product_id", and the modify existing sql query adding WHERE clause. But that SQL query is sooo confusing: foreach ($suppliers as $key => $supplier) { $sql = ' SELECT DISTINCT(ps.`id_product`) FROM `'._DB_PREFIX_.'product_supplier` ps JOIN `'._DB_PREFIX_.'product` p ON (ps.`id_product`= p.`id_product`) '.Shop::addSqlAssociation('product', 'p').' WHERE ps.`id_supplier` = '.(int)$supplier['id_supplier'].' AND ps.id_product_attribute = 0'. ($active ? ' AND product_shop.`active` = 1' : ''). ' AND product_shop.`visibility` NOT IN ("none")'. ($all_groups ? '' :' AND ps.`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` '.$sql_groups.' )'); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); $suppliers[$key]['nb_products'] = count($result); } } Don't have idea how to achive that :/ Any simplier solution to retrive all suppliers for given product on product page?
  14. Using prestashop 1.5.6.1. We can actually assign several suppliers for one product. Lets say its Apple and Shure. And we HAVE TO choose default supplier for that product. Ok lets say its Apple. Now on product page i have in variables only Apple supplier informations. Is there any way to pass object with list of ALL suppliers assigned to this product? (not only one marked as default?) Something like: [suppliers_tab] [1] [supplier id] => 1 [supplier name] => Apple [supplier desc] => ... [2] [supplier id] => 2 [supplier name] => Shure [supplier desc] => .... Let's say i would like to show list of all suppliers for this product on product page. Any help with this? Thanks in advance.
  15. I have question which expands problem discussed here. I'm using prestashop 1.5.6.1 We can actually assign several suppliers for one product. Lets say its Apple and Shure. And we HAVE TO choose default supplier for that product. Ok lets say its Apple. Now on product page i have in variables only Apple supplier informations. Is there any way to pass object with list of ALL suppliers assigned to this product? (not only one marked as default?) Something like: [suppliers_tab] [1] [supplier id] => 1 [supplier name] => Apple [supplier desc] => ... [2] [supplier id] => 2 [supplier name] => Shure [supplier desc] => .... Let's say i would like to show list of all suppliers for this product on product page. Any help with this? Thanks in advance.
×
×
  • Create New...