boran Posted January 15, 2009 Share Posted January 15, 2009 Hi,When a buyer selects a downloadable product, it tries to manage the stock with messages like:1 item in stockWarning: Last items in stock!Is there a way to disable stock management for these products, since its not relevant.Thanks in avance, Link to comment Share on other sites More sharing options...
jhnstcks Posted January 15, 2009 Share Posted January 15, 2009 Theres an option in the BO>preferences>products to disable/enable stock management. 2 Link to comment Share on other sites More sharing options...
boran Posted January 18, 2009 Author Share Posted January 18, 2009 Yes, thanks. Thats for all products though.The idea would be to disable stock management for downloadable products. Link to comment Share on other sites More sharing options...
TropischBruin Posted January 18, 2009 Share Posted January 18, 2009 This would mean that you should create a difference in the query when a check on the stock is done for "virtual" and "real" products.This is something that needs to be coded in you PS files. Link to comment Share on other sites More sharing options...
boran Posted January 18, 2009 Author Share Posted January 18, 2009 As a start I changed in themes/prestashop/product.tpl <!-- number of item in stock --> quantity == 0)} style="display:none;"{/if}> to downloadable)) && ($display_qties != 1 || ($allow_oosp && $product->quantity == 0) )} style="display:none;"{/if}> but that didn't seem to make any difference.I'm new to PS code changes, suggestions on where to start? Link to comment Share on other sites More sharing options...
TropischBruin Posted January 18, 2009 Share Posted January 18, 2009 I think that you should first identify and separate the virtual products from the real products before you can build a stock-filter. Link to comment Share on other sites More sharing options...
boran Posted January 18, 2009 Author Share Posted January 18, 2009 I have a category for them, and in the product settings there is a a tickbox "Is this a downloadable product?" which is mapped to a label is_virtual_good. I'm not sure how to reference this flag from $product in themes/prestashop/product.tpl though.There is a not a downloadable flag in the products, its a separate table.Perhaps someone could provide links or tips on accessing the product objects from .tpl files? Link to comment Share on other sites More sharing options...
jaumeortola Posted February 14, 2009 Share Posted February 14, 2009 In my shop I have downloadables and non-downloadables products. I need to stop managing stocks for downloadable products. I have added these lines in Product.php, and it works. public static function updateQuantity($product) { if (!is_array($product)) die (Tools::displayError()); /* if the product is downloadable, don't update quantity */ $result = Db::getInstance()->getRow(' SELECT * FROM `'._DB_PREFIX_.'product_download'.'` WHERE `id_product` = '.intval($product['id_product'])); if ($result) return true; ... Link to comment Share on other sites More sharing options...
boran Posted February 14, 2009 Author Share Posted February 14, 2009 Thanks, so this will stop the stock from being decremented when a sale is made?The SQL might be more efficient if one just did "SELECT id_product_download" as opposed to "SELECT *"?Or perhaps, use getIdFromIdProduct() from ProductDownload.php?Maybe your code is also needed in checkQuantities() in Cart.php?And product-sort.php?As these are all places where PS_STOCK_MANAGEMENT is referenced.But what about getting rid of "Availability: 1000 items in stock" on the item details page?I think that needs to be handled on the display level, thus themes/prestashop/product.tpl?There is a $display_qties in themes/prestashop/product.tpl, but I don't understand how it is set, can you help? Link to comment Share on other sites More sharing options...
boran Posted February 14, 2009 Author Share Posted February 14, 2009 Hmm. So I created a method in Product.php static public function getProductIsDownloadable($id_product) { $result = Db::getInstance()->getRow(' SELECT id_product_download FROM `'._DB_PREFIX_.'product_download'.'` WHERE `id_product` = '.intval($id_product)); if ($result) return true; else return false; } Then added to getProductProperties(): $row['is_downloadable'] = Product::getProductIsDownloadable($row['id_product']); /* SB */ And in "themes/product.tpl" reference is_downloadable: quantity == 0 && !$product->available_later) || (!$product->available_now && $display_qties != 1) } style="display:none;"{/if}> {l s='Availability:'} "Availability:" is still shown on the stock page, so there must be a bug in my logic above, in how to get the downloadable flag onto the smarty template and control the display based on that. Link to comment Share on other sites More sharing options...
boran Posted February 25, 2009 Author Share Posted February 25, 2009 Ok, the issues is resolved, a patch that does the job has been attached to this post.Changes are needed to classes/Product.php product.php classes/Cart.php themes/default/product.tplI'll put it up on boran.com/presta where I keep my notes. Link to comment Share on other sites More sharing options...
boran Posted February 26, 2009 Author Share Posted February 26, 2009 I'm trying to attach a patch to this post, but it is not showing up.Is there some trick to get attachments to work correctly?I've posted it here:http://boran.com/sites/boran.com/files/ps_patch_forum_10649_0.txt Link to comment Share on other sites More sharing options...
Recommended Posts