Jump to content

hagbard_2605

Members
  • Posts

    2
  • Joined

  • Last visited

Profile Information

  • First Name
    Severin
  • Last Name
    Brettmeister

hagbard_2605's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Ok, I got it a little further. If I add my new database column to the getProducts function in the Cart.php, it works. Now it looks like that: // Build SELECT $sql->select('cp.`id_product_attribute`, p.`packing_unit_for_groups`, cp.`id_product`, cp.`quantity` AS cart_quantity, cp.id_shop, pl.`name`, p.`is_virtual`, pl.`description_short`, pl.`available_now`, pl.`available_later`, product_shop.`id_category_default`, p.`id_supplier`, p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`, product_shop.`available_for_order`, product_shop.`price`, product_shop.`active`, product_shop.`unity`, product_shop.`unit_price_ratio`, stock.`quantity` AS quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, p.`weight`, p.`date_add`, p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category, CONCAT(LPAD(cp.`id_product`, 10, 0), LPAD(IFNULL(cp.`id_product_attribute`, 0), 10, 0), IFNULL(cp.`id_address_delivery`, 0)) AS unique_id, cp.id_address_delivery, product_shop.advanced_stock_management, ps.product_supplier_reference supplier_reference, IFNULL(sp.`reduction_type`, 0) AS reduction_type'); Can somebody explain to me, how to override that class with as less duplicated code as possible? In the moment I'm overriding the whole function (getProducts).
  2. Hi, I added a new field to my product class and need to access this field in the cart template (product line). Unfortunately I don't understand how to override/extend the Cart.php (?) properly to get that new field. What I've done so far: I added a product field "packing_unit_for_groups" via overriding Product.php: <?php Class Product extends ProductCore { public $packing_unit_for_groups; public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null) { self::$definition['fields']['packing_unit_for_groups'] = array('type' => self::TYPE_INT, 'shop' => true, 'validate' => 'isUnsignedInt'); parent::__construct($id_product, $full, $id_lang, $id_shop, $context); } } ?> With my custom module I can save/retrieve data from this new field in the database (in table 'ps_product'). In the Template product.tpl I've access to that new field thanks to the following code in my module: public function prepareNewTab() { $this->context->smarty->assign(array( 'packing_unit' => $this->getCustomField((int)Tools::getValue('id_product')), )); } public function getCustomField($id_product) { $result = Db::getInstance()->getValue('SELECT packing_unit_for_groups FROM '._DB_PREFIX_.'product WHERE id_product = ' . (int)$id_product); return (int)$result; } Now I'm stuck at the cart because I have no clue how/where to override. I guess I need to extend the "public function getProducts" in the Cart.php but don't know how?! I just want to get my new field in the shopping-cart-product-line.tpl. In my product.tpl I can get the new field with {$product->packing_unit_for_groups} but in the shopping cart the {$product} does not include my new field. I appreciate any help! Thanks!
×
×
  • Create New...