public function add($autodate = true, $null_values = false) { if (!parent::add($autodate, $null_values)) { return false; } $product = new Product((int) $this->id_product); if ($product->getType() == Product::PTYPE_VIRTUAL) { StockAvailable::setProductOutOfStock((int) $this->id_product, 1, null, (int) $this->id); } else { StockAvailable::setProductOutOfStock((int) $this->id_product, StockAvailable::outOfStock((int) $this->id_product), null, $this->id); } SpecificPriceRule::applyAllRules(array((int) $this->id_product)); return true; }
/** * @return array * @throws \Exception * @author Panagiotis Vagenas <*****@*****.**> * @since 150213 */ public function createProductsArray() { $products = \Product::getProducts($this->defaultLang, 0, 0, 'id_product', 'ASC', false, $this->Options->getValue('include_disabled')); $backOrdersAvailString = $this->Options->getValue('avail_backorders'); $outOfStockAvailString = $this->Options->getValue('avail_outOfStock'); $backOrdersInclude = $this->String->is_not_empty($backOrdersAvailString); $outOfStockInclude = $this->String->is_not_empty($outOfStockAvailString); foreach ((array) $products as $key => $product) { $p = new \Product($product['id_product']); // TODO Check for product avail etc $hasStock = $p->getRealQuantity($p->id) > 0; // TODO Is this a convenient way? if ($p->getType() != 0 || $p->visibility == 'none' || $p->available_for_order == 0) { unset($products[$key]); // TODO Log skipped product continue; } if (!$hasStock) { // TODO backOrdersAllowed not working as expected if ($p->getRealQuantity($p->id) == 0 && !$outOfStockInclude) { unset($products[$key]); // TODO Log skipped product continue; } else { if ($p->getRealQuantity($p->id) < 0 && (!$backOrdersInclude || !$this->backOrdersAllowed($p))) { // quantity < 0 unset($products[$key]); // TODO Log skipped product continue; } } } $pushArray = $this->getProductArray($p); if (!empty($pushArray)) { $products[$key] = $pushArray; } else { // TODO Log skipped product unset($products[$key]); } } return $products; }
public static function newInstance($pId) { $warehouse = new Warehouse(); $product = new Product($pId); $productType = $warehouse->getProductTypeInfo($product->getType())['ptName']; $sku = self::getProperInstance($productType); $sku->setProductId($pId); return $sku; }
<?php require_once 'product.php'; $myProduct = new Product('php for dummies', 'boek'); $myProduct2 = new Product('hoi', 'film'); // $myProduct-> getTitle(); echo "Title: "; echo $myProduct->getTitle(); echo '<br>'; echo 'dit is een:'; echo $myProduct->getType(); echo '<br>'; echo $myProduct2->getTitle(); echo '<br>'; echo 'dit is een:'; echo $myProduct2->getType();