Jump to content

Paul C

  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by Paul C

  1. Can you post an export of the table structure? Have you looked in the server error log to see if there's an error? The reason I mention an uninstall/install is because people often forget that the registerHook() call is only made during an install, so you can't add extra functions to a module that's already installed and expect them to work
  2. Assumuming that you add a $this->registerHook('actionObjectProductDeleteAfter') in the module's install() method (and reset or uninstall/install the module before testing) I would probably be tempted to use: public function hookActionObjectProductDeleteAfter($params) { $product = $params['object']; if ($product instanceof Product) Db::getInstance()->execute('DELETE FROM products WHERE ID ='.$product->id); }
  3. You can use the cart id instead of the order id. The cart should contain everything the payment gateway needs and an order can always be linked to cart id after the call to validateOrder. Up until the point that validateOrder is called - the cart_id IS the order_id if that makes sense....
  4. Not sure what this would give you? You could certainly scan a directory and create a product for each image, yes. Problem is you would need to supply a name, some sort of description, a price, even maybe a quantity. Unless you have a structured way of naming the files this is going to be challenging isn't it? If you do name the files with something that contains all the elements, separated in some way - surely you would be just as quick creating a csv file? Maybe I'm missing something....
  5. This has been asked a few time and I can't remember if I ever provided my method (still ps 1.5.x but should be fine in 1.6.x). First you need a function to calculate the group price: /** * Get product group price * Support function for hookDisplayRightColumnProduct() * @param integer $id_product Product id * @param integer $id_group (default value: NULL) * @param boolean $usetax prices including/excluding taxes (optional) * @param integer $id_product_attribute Product attribute id (optional). * NULL does apply the default combination price impact. * @param variable_reference $specificPriceOutput. * If a specific price applies regarding the previous parameters, this variable is filled with the corresponding SpecificPrice object * @return float Product price */ public static function getGroupPriceStatic($id_product, $id_group = null, $usetax = true, $price_display_precision = 6, $id_product_attribute = null, &$specific_price_output = null) { $context = Context::getContext(); // Basic checks if (!Validate::isBool($usetax) || !Validate::isUnsignedId($id_product)) die(Tools::displayError()); // Initialise defaults if (!$id_group) $id_group = Configuration::get('PS_DEFAULT_CUSTOMER_GROUP'); $id_currency = (int)Validate::isLoadedObject($context->currency) ? $context->currency->id : Configuration::get('PS_CURRENCY_DEFAULT'); $id_country = (int)Validate::isLoadedObject($context->currency) ? (int)$context->country->id : Configuration::get('PS_COUNTRY_DEFAULT'); $id_state = 0; $zipcode = 0; // Populate address parameters if ($id_address = $context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')}) { $address_infos = Address::getCountryAndState($id_address); if ($address_infos['id_country']) { $id_country = (int)$address_infos['id_country']; $id_state = (int)$address_infos['id_state']; $zipcode = $address_infos['postcode']; } } else if (isset($context->customer->geoloc_id_country)) { $id_country = (int)$context->customer->geoloc_id_country; $id_state = (int)$context->customer->id_state; $zipcode = (int)$context->customer->postcode; } // Verify tax options (parameter may be overridden here) if (Tax::excludeTaxeOption()) $usetax = false; if ($usetax != false && !empty($address_infos['vat_number']) && $address_infos['id_country'] != Configuration::get('VATNUMBER_COUNTRY') && Configuration::get('VATNUMBER_MANAGEMENT')) $usetax = false; // Calculate price return Product::priceCalculation( (int)$context->shop->id, $id_product, $id_product_attribute, $id_country, $id_state, $zipcode, $id_currency, $id_group, 1, $usetax, $price_display_precision, false, true, true, $specific_price_output, true, 0, false, 0, 1 ); } I placed the above in a module. In my case I wanted to have a RRP, so stored that as an absolute group price on a per product basis. To get the value into the templates I added an override in classes/Product.php (EDIT: To be clear that's in override/classes/Product.php and requires additional code to be fully function i.e. a class declaration): public static function getTaxesInformations($row, Context $context = null) { $row = parent::getTaxesInformations($row, $context); $module = Module::getInstanceByName('yourmodulethatcontainsthefunction'); $row['rrp_price'] = $module->getGroupPriceStatic($row['id_product'], (int)MembershipCard::getRRPGroup(), true, 6, ((isset($row['id_product_attribute']) AND !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : null)); return $row; } You'll see in the above the function MembershipCard::getRRPGroup() - this just returns the id of the customer group I used to store the recommended retail prices and would be replaced with the id of the customer discount group you want to show. Obviously you then need to add markup as appropriate in your templates. Should appear wherever there's a reference to a product just the same as the price does (but under a different member variable name, of course). If you have multiple groups then you could loop through all of them adding the prices to a suitable variable (or array) to let you display them all. Paul
  6. Did you ensure that your module is the last hook to execute (Module -> positions)? The problem is likely to do with the order of execution and it will depend greatly on where the variable is assigned (controller or module) and where the hook that you're using in your module is executed with respect to the default assignment. IIRC you can also use the following to remove the assigned variable altogether: $smarty->clear_assign('category');
  7. The WHERE clause is specifying that records matching ANY of the group ids in the set should be selected. EDIT 1: Removed rest of answer because it was wrong!! EDIT 2: Having another go.... SELECT * FROM vs_customer c LEFT JOIN vs_customer_group g ON g.id_customer = c.id_customer INNER JOIN vs_group_lang l ON l.id_group = g.id_group WHERE c.id_lang = 2 AND g.id_group IN('.$_GET['ids'].') GROUP BY c.id_customer HAVING COUNT(DISTINCT g.id_group) = '.count($_GET['ids'])
  8. Well done fixing it - things like that can be really hard to spot. If it's any consolation using the objects might not have helped unless you set visibility "on" by default
  9. I would always recommend using the "proper" Prestashop objects when manipulating the database (e.g. Product) as that way you're guaranteed that any changes in the underlying structure will be catered for - otherwise you face issues like the one you're experiencing! My own xml importer using objects so I don't HAVE to know what tables to update If you want to continue down your route then I suggest that you install a copy of MySQL Workbench (It's free from Oracle) and then you can study the database relationships by opening up /docs/dev/dbmodel.mwb
  10. Mark, That's not so bad as it's an actual fix committed to the core. The change was made 11 months ago though so it makes me wonder what version of Prestashop you're running? It's a good idea in circumstances like this to upgrade to the latest if you can! (Note that if you have a cpanel hosting package you can do small edits like this by downloading, editing and uploading from the FileManager built in).
  11. You should never, ever modify core files as any changes you make will be lost when you next upgrade your store. The correct way to change the behaviour of your store is by using a module/hook combination or an override (if there's no other choice). It would be useful to post a link to the instructions you have and I'm sure someone can point out a much better way of achieving the end result, because modifying that file isn't the way to go.
  12. Actually you're creating all sorts of problems for yourself if you go and edit that file. Instead create a subdirectory in your theme called pdf and copy that "master" invoice.tpl file into this new directory. You can then makes your changes to that "overridden" version of the file and your changes will persist after an upgrade.
  13. You can take a look at the source for http://fontawesome.io/ to see a practical implementation (it's designed for the Bootstrap framework but is an excellent general example regardless). There's also some good background reading here: http://www.webdirections.org/blog/the-return-of-font-embedding-to-the-web/ including information about compatibility and standards for font embedding. Have fun!
  14. Have you looked at just changing the wording for the "gift wrapping" option and using that? Would be a LOT simpler, while still providing the choice. You would probably also need to add a paragraph of text by way of explanation.
  15. Well the "best answer" doesn't mention it so not sure which post you mean?
  16. Can I ask why you wouldn't just use {$category->id}. That would seem the most sensible approach to me, unless I'm missing something....
  17. I'm not familiar with that module but one thought is that there is one or more files relating to it in the overrides folder. Worth looking in there...
  18. I've specified specific group pricing in a custom importer and all you have to do is create one or more new SpecificPrice object(s). You can then initialise the object for a price specific to a Shop, Shop Group, Customer group, country, currency etc. Just make sure that you specify 'amount' as the 'reduction_type' data member of the class. I think an importer would be the way to go as it provides for the greatest flexibility, especially if you don't want to be forced into rules that have several exceptions (e.g. all product from manufacturer 'Y' have different price reductions). The key to a functional custom importer like this (especially when you want to import price updates and not just one-off product imports) is to be able to provide a unique reference in the import file - e.g. a unique supplier/manufacturer reference. That way the product_id becomes arbitrary. The latter is important should you ever need to migrate or merge the product data in the store with another site. What format is the information supplied on the products? CSV/XML? for 18,000 SKUs I'm assuming that you're not generating the input data by hand.....
  19. Iain, I'm really not sure from the example what you're trying to do as you're declaring a global variable and then not using it.. If you think of $this->context->smarty as a globally accessible variable then you can do the following: public function first() { $variable = 'Some value'; $this->context->smarty->assign('variable', $variable); } public function second() { // Get the value stored on the "first" function $variable = $this->context->smarty->tpl_vars['variable']->value // Change the value and then.... $variable = 'Modified value'; // Save it in the template again $this->context->smarty->assign('variable', $variable); } Note that you don't have to assign the same smarty variable in every function unless you want to change its value - it will persist across functions.
  20. If there's no default attribute set on the product then this will happen. If you go to the combinations tab for the product and set one of the combinations as default then the price will display correctly. Unfortunately this happens even if the combinations have no price impact!!
  21. Did you delete cache/class_index.php after you added your override file? If not then it will be ignored and the "Core" class gets used instead.
  22. The table is db-prefix_category_product. Maps id_category to id_product (and includes a manual position within the category). Via the object model: $product = new Product($id); $categories = $product->getCategories(); To set them: $product = new Product($id); $success = $product->updateCategories(array('1','3','4')) $product->id_category_default = '3'; $product->update();
  23. You should be able to use Tools::getValue('field_name') to get the value of the select.
  24. It's declared in the source as: abstract class DbCore {} During initialisation - as part of the override system - the "proper" Db class will be instantiated which is why you can't find a declaration.
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More