Ergebnis 1 bis 3 von 3

Thema: Neues Produkttyp ohne attributen

  1. #1
    Contao-Nutzer
    Registriert seit
    23.01.2011.
    Beiträge
    35

    Standard Neues Produkttyp ohne attributen

    Ich möchte eine Erweiterung machen welche ich einfach für neue Webshops installieren könte. Eine der Anforderungen eines bestimmten Produkttyp ist, dass es immer bestimmte Attributen hatte, die nicht Standard sind ins Isotope. Zur Vereinfachung der Installation der Erweiterung und für die Geschwindigkeit der PHP Code möchte ich die Felder auf das Produkt hinzu, um die Datenbank und DCA.

    Kann mir jemand erklären, wie die Paletten für Produkttypen zusammengesetzt sind, da sie nicht in der tl_iso_products DCA Datei steht. Ich weiß wie ich ein Feld mache so das es wird aufgenommen, aber ich brauche einige Felder nur in eine Produkttyp und habe nicht gefunden, wie das zu erreichen.

    bearbeited:
    Besser gesagt, ich will bestimmte Attribute für bestimmte Produktklassen erfordern. Die Attribute werden nicht für andere Produkte erfordert, vielleicht sogar unsichtbar.

    In English:
    I'd like to create an extension I can easily install for new webshops. One of the requirements of a certain product type is that it will allways have certain attributes that are not standard. For ease of installation of the extension and for speed of all code I'd like to add the fields to the product type to the database and dca.

    Can someone explain to me how the palettes for producttypes are composed, as they are not in the tl_iso_products dca file. I know I can set a field so it will be included, but I need some fields in 1 product type only and haven't found how to achieve that.

    edit:
    Better put; I want to force certain attributes for certain product classes. The attributes are not required for other products, perhaps even invisible if possible.
    Geändert von Ruud (21.06.2012 um 20:18 Uhr)

  2. #2
    Contao-Nutzer
    Registriert seit
    23.01.2011.
    Beiträge
    35

    Standard

    Gibt es auch einen besseren Weg als was ich mir jetz hab gedacht?

    Ich muss noch herausfinden, wie im Backend bei der Bearbeitung von Produkttypen ich die ausgewählte Produkttyp erkennen kann und die DCA ändern.

    config.php:
    PHP-Code:
    $GLOBALS['ISO_PRODUCT']['tyre'] = array
    (
        
    'class' => 'IsotopeProductSpecial',
    );

    $GLOBALS['ISO_HOOKS']['productAttributes'][] = array('IsotopeSpecialshop''enforceSpecialAttributes'); 
    IsotopeSpecialshop.php:
    PHP-Code:
    public function enforceSpecialAttributes(&$arrAttributes, &$arrVariantAttributesIsotopeProduct &$objProduct)
    {
        if (!(
    $objProduct instanceof IsotopeProductSpecial))
        {
            return;
        }
        
        
    // Adding the attributes to $arrAttributes
        
    ...

    tl_iso_producttypes.php
    PHP-Code:
    ...
    $intAttrCnt count($GLOBALS['TL_DCA']['tl_iso_producttypes']['fields']['attributes']['default']) + 1;
    $GLOBALS['TL_DCA']['tl_iso_producttypes']['fields']['attributes']['default']['ss_ean'] = array('enabled'=>1'position'=>$intAttrCnt++, 'tl_class_select'=>'clr'); 
    tl_iso_products.php
    PHP-Code:
    $GLOBALS['TL_DCA']['tl_iso_products']['fields']['ss_ean'] = array
        (
            
    'label' => ...
    ...
        ); 
    database.sql
    Code:
    CREATE TABLE `tl_iso_products` (
      `ss_ean` varchar(32) NOT NULL default ''
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
    Geändert von Ruud (22.06.2012 um 09:08 Uhr)

  3. #3
    Contao-Nutzer
    Registriert seit
    23.01.2011.
    Beiträge
    35

    Standard

    Ich habs! Die unterhalb macht die HOOKS obsolet. Can someone tell me if there would be an even better way??

    tl_iso_producttypes.php
    PHP-Code:
    // Add an onload callback that makes the required tyre attributes required for tyre products only
    $GLOBALS['TL_DCA']['tl_iso_producttypes']['config']['onload_callback'][] = array('tl_iso_producttypes_specialshop''requireSpecialAttributes');

    ...

    class 
    tl_iso_producttypes_specialshop extends Backend
    {
        public function 
    requireSpecialAttributes($dc)
        {
            
    // todo; $dc->table or plain tl_iso_producttypes. Couldn't be anything else...
            
    $dcClass $this->Database->prepare("SELECT * FROM " $dc->table " WHERE id=?")
                                    ->
    limit(1)
                                    ->
    execute($dc->id)
                                    ->
    class;
                                            
            if (
    $dcClass == 'special')
            {
                
    $GLOBALS['TL_DCA']['tl_iso_products']['fields']['ss_ean']['attributes']['fixed'] = true;
            }
        }

    Geändert von Ruud (22.06.2012 um 07:09 Uhr)

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •