Attributes can be set in products now
This commit is contained in:
33
application/ProductAttribute/ProductAttribute.php
Normal file
33
application/ProductAttribute/ProductAttribute.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
class ProductAttribute extends mfBaseModel {
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
if($name == "networks") {
|
||||
$this->networks = [];
|
||||
$productNetworks = ProductNetworkModel::search(['product_id' => $this->id]);
|
||||
foreach($productNetworks as $pnet) {
|
||||
$this->networks[$pnet->network_id] = new Network($pnet->network_id);
|
||||
}
|
||||
return $this->networks;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name."_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user