Jump to content

Νεά μεταβλητή στο product


Recommended Posts

Θέλω να προσθέσω μία μεταβλητή στο $product όπου θα την χρησιμοποιώ και στο product page και στα product listing (category, search, manufacturer κτλ)

Την μεταβλητή θα την υπολογίζω στον controller και μετά στο template ανάλογα με την τιμή θα εμφανίζω κάτι.

Δοκίμασα να κάνω override το product class

<?php 
Class Product extends ProductCore
{
    public $show_discount = 1;
    public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
    {
        self::$definition['fields']['show_discount'] = array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'size' => 1);
        parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
    }
}
?>

και μετά με override στον controller δίνω τιμή στο show_discount.

Το πρόβλημά μου είναι ότι το show_discount έχει προστεθεί και στο web service με αποτέλεσμα να μην μπορώ να κάνω save πάνω στο product.

Ακόμη η μεταβλητή υπάρχει κανονικά στο product page , αλλά δεν υπάρχει στο product listing (το βλέπω με var dump).

Μπορεί κάποιος να με κατατοπίσει?

Link to comment
Share on other sites

  • 4 weeks later...
22 hours ago, eyaggelos said:

@sanctusmob  δες μια το module αυτό https://github.com/vgoritsas/Extrafieldprice_ps17

Κάνεις override την class Product. Αυτό δημιουργεί νέα variable και στο web service (που δεν το θέλω).

Το έκανα με προσθήκη variable στο smarty μέσα από τον controller. Αλλά πάλι δεν παίζει στο category view (το ψάχνω).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...