Example #1
0
    public function save()
    {
        if ($this->getActiveStatus()) {
            // verify SKU if it gets published
            $this->verify();
        }
        $db = \App::get('db');
        $warehouse = new Warehouse();
        $sId = $warehouse->saveSku($this);
        $this->setId($sId);
        // Save options
        if (isset($this->data->options)) {
            $sql = 'DELETE FROM `#__storefront_sku_options` WHERE `sId` = ' . $db->quote($this->getId());
            $db->setQuery($sql);
            $db->query();
            foreach ($this->data->options as $oId) {
                if ($oId && $oId > 0) {
                    $sql = 'INSERT INTO `#__storefront_sku_options` (`sId`, `oId`)
						VALUES (' . $db->quote($this->getId()) . ', ' . $db->quote($oId) . ')';
                    $db->setQuery($sql);
                    $db->query();
                }
            }
        }
        return $sId;
    }