public function save(Product $product) { $flattened = $this->_flatten($product->getDetails()); $this->_transaction->add("\n\t\t\tDELETE FROM\n\t\t\t\tproduct_detail\n\t\t\tWHERE\n\t\t\t\tproduct_id = :productID?i\n\t\t", ['productID' => $product->id]); foreach ($flattened as $detail) { $this->_transaction->add(' INSERT INTO product_detail ( product_id, name, value, value_int, locale ) VALUES ( :productID?i, :name?s, :value?s, :value?i, :locale?s ) ', array_merge($detail, ['productID' => $product->id])); } if (!$this->_transOverridden) { $this->_transaction->commit(); } }
protected function _getProductDetailsForm() { return $this->get('field.form')->generate($this->_product->getDetails(), ['action' => $this->generateUrl('ms.commerce.product.edit.details.action', ['productID' => $this->_product->id])]); }
protected function _getDefaultValues(Product $product) { $defaultValues = $product->getDetails()->flatten(); $defaultValues['title'] = !empty($defaultValues['title']) ? $defaultValues['title'] : $product->name; return $defaultValues; }
public function getProductDisplayName(Product $product) { $name = $product->displayName ?: $product->name; return $product->getDetails()->author ? $product->getDetails()->author . ' - ' . $name : $name; }
public function getDetails() { $this->_load('details'); return parent::getDetails(); }