/** * Delete a product attribute * * @param int $idAttribute The attribute ID * @param int $idProduct The product ID * * @return array */ public function ajaxProcessDeleteProductAttribute($idAttribute, $idProduct) { if (!\CombinationCore::isFeatureActive()) { return false; } if ($idProduct && \ValidateCore::isUnsignedId($idProduct) && \ValidateCore::isLoadedObject($product = new \ProductCore($idProduct))) { if (($depends_on_stock = \StockAvailableCore::dependsOnStock($idProduct)) && \StockAvailableCore::getQuantityAvailableByProduct($idProduct, $idAttribute)) { return array('status' => 'error', 'message' => 'It is not possible to delete a combination while it still has some quantities in the Advanced Stock Management. You must delete its stock first.'); } else { $product->deleteAttributeCombination((int) $idAttribute); $product->checkDefaultAttributes(); \ToolsCore::clearColorListCache((int) $product->id); if (!$product->hasAttributes()) { $product->cache_default_attribute = 0; $product->update(); } else { \ProductCore::updateDefaultAttribute($idProduct); } if ($depends_on_stock && !\StockCore::deleteStockByIds($idProduct, $idAttribute)) { return array('status' => 'error', 'message' => 'Error while deleting the stock'); } else { return array('status' => 'ok', 'message' => 'Successful deletion'); } } } else { return array('status' => 'error', 'message' => 'You cannot delete this attribute.'); } }
public function hydrate(array $data, $id_lang = null) { parent::hydrate($data, $id_lang); if (!isset($data['physical_quantity_remainder'])) { PP::hydrateQty($this, 'physical_quantity', $data['physical_quantity'] + $this->physical_quantity_remainder); } if (!isset($data['usable_quantity_remainder'])) { PP::hydrateQty($this, 'usable_quantity', $data['usable_quantity'] + $this->usable_quantity_remainder); } }