public function onBeforeWrite() { parent::onBeforeWrite(); // Downloadable products have 0 weight and Pack Size $this->Weight = 0; $this->PackSize = 0; }
public function onBeforeWrite() { parent::onBeforeWrite(); // Loop through our children and save (incase we need to set prices) foreach ($this->ChildProducts() as $product) { $write = false; if (!$product->BasePrice && $this->BasePrice) { $product->BasePrice = $this->BasePrice; $write = true; } if ($this->isChanged("BasePrice")) { $product->BasePrice = $this->BasePrice; $write = true; } if ($write) { $product->write(); } } }
function onBeforeWrite() { parent::onBeforeWrite(); $this->MetaTitle = $this->Title; $this->MetaDescription = strip_tags($this->Content); if ($this->Sort < self::$minimum_sort) { $this->Sort = $this->Sort + self::$minimum_sort; } }
/** * remove any non-products from the list. * */ function onBeforeWrite() { parent::onBeforeWrite(); $includedProducts = $this->IncludedProducts(); if ($includedProducts) { foreach ($includedProducts as $includedProduct) { if (!$includedProduct instanceof Product) { $includedProducts->remove($includedProduct); } } } $this->Price = $this->NewPrice; }