public static function setVal($metaKey, $elementKey, $elementId, $value)
    {
        $data = self::create()
            ->filterByMetaKey($metaKey)
            ->filterByElementKey($elementKey)
            ->filterByElementId($elementId)
            ->findOne()
        ;

        if (null === $data) {
            $data = new MetaData();
            $data->setMetaKey($metaKey);
            $data->setElementKey($elementKey);
            $data->setElementId($elementId);
        }

        $data->setValue($value);

        $data->save();
    }
public static function setVal($metaKey, $elementKey, $elementId, $value)
    {
        $data = self::create()
            ->filterByMetaKey($metaKey)
            ->filterByElementKey($elementKey)
            ->filterByElementId($elementId)
            ->findOne()
        ;

        if (null === $data) {
            $data = new MetaData();
            $data->setMetaKey($metaKey);
            $data->setElementKey($elementKey);
            $data->setElementId($elementId);
        }

        $data->setValue($value);

        $data->save();
    }
public static function setVal ( $ metaKey , $ elementKey , $ elementId , $ value ) { $ data = self :: create ( ) -> filterByMetaKey ( $ metaKey ) -> filterByElementKey ( $ elementKey ) -> filterByElementId ( $ elementId ) -> findOne ( ) ; if ( null === $ data ) { $ data = new MetaData ( ) ; $ data -> setMetaKey ( $ metaKey ) ; $ data -> setElementKey ( $ elementKey ) ; $ data -> setElementId ( $ elementId ) ; } $ data -> setValue ( $ value ) ; $ data -> save ( ) ; }
Add or update the MetaData element

@param string $metaKey    the meta Key
@param string $elementKey the element Key : product, category, ...
@param int    $elementId  the element id
Add or update the MetaData element