| @@ 36-72 (lines=37) @@ | ||
| 33 | * @link https://github.com/techdivision/import-product |
|
| 34 | * @link http://www.techdivision.com |
|
| 35 | */ |
|
| 36 | class StockItemCreateProcessor extends AbstractCreateProcessor |
|
| 37 | { |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Implements the CRUD functionality the processor is responsible for, |
|
| 41 | * can be one of CREATE, READ, UPDATE or DELETE a entity. |
|
| 42 | * |
|
| 43 | * @param array $row The data to handle |
|
| 44 | * @param string|null $name The name of the prepared statement to execute |
|
| 45 | * |
|
| 46 | * @return void |
|
| 47 | */ |
|
| 48 | public function execute($row, $name = null) |
|
| 49 | { |
|
| 50 | ||
| 51 | // load the field names |
|
| 52 | $keys = array_keys($row); |
|
| 53 | ||
| 54 | // create a unique name for the prepared statement |
|
| 55 | $name = sprintf('%s-%s', $name, md5(implode('-', $keys))); |
|
| 56 | ||
| 57 | // query whether or not the statement has been prepared |
|
| 58 | if (!$this->hasPreparedStatement($name)) { |
|
| 59 | // remove the entity status from the keys |
|
| 60 | unset($keys[array_search(EntityStatus::MEMBER_NAME, $keys)]); |
|
| 61 | ||
| 62 | // create the prepared UPDATE statement |
|
| 63 | $statement = sprintf($this->getUtilityClass()->find(SqlStatements::CREATE_STOCK_ITEM), implode(',', $keys), implode(',:', $keys)); |
|
| 64 | ||
| 65 | // prepare the statement |
|
| 66 | $this->addPreparedStatement($name, $this->getConnection()->prepare($statement)); |
|
| 67 | } |
|
| 68 | ||
| 69 | // pass the call to the parent method |
|
| 70 | return parent::execute($row, $name); |
|
| 71 | } |
|
| 72 | } |
|
| 73 | ||
| @@ 36-72 (lines=37) @@ | ||
| 33 | * @link https://github.com/techdivision/import-product |
|
| 34 | * @link http://www.techdivision.com |
|
| 35 | */ |
|
| 36 | class StockStatusCreateProcessor extends AbstractCreateProcessor |
|
| 37 | { |
|
| 38 | ||
| 39 | /** |
|
| 40 | * Implements the CRUD functionality the processor is responsible for, |
|
| 41 | * can be one of CREATE, READ, UPDATE or DELETE a entity. |
|
| 42 | * |
|
| 43 | * @param array $row The data to handle |
|
| 44 | * @param string|null $name The name of the prepared statement to execute |
|
| 45 | * |
|
| 46 | * @return void |
|
| 47 | */ |
|
| 48 | public function execute($row, $name = null) |
|
| 49 | { |
|
| 50 | ||
| 51 | // load the field names |
|
| 52 | $keys = array_keys($row); |
|
| 53 | ||
| 54 | // create a unique name for the prepared statement |
|
| 55 | $name = sprintf('%s-%s', $name, md5(implode('-', $keys))); |
|
| 56 | ||
| 57 | // query whether or not the statement has been prepared |
|
| 58 | if (!$this->hasPreparedStatement($name)) { |
|
| 59 | // remove the entity status from the keys |
|
| 60 | unset($keys[array_search(EntityStatus::MEMBER_NAME, $keys)]); |
|
| 61 | ||
| 62 | // create the prepared UPDATE statement |
|
| 63 | $statement = sprintf($this->getUtilityClass()->find(SqlStatements::CREATE_STOCK_STATUS), implode(',', $keys), implode(',:', $keys)); |
|
| 64 | ||
| 65 | // prepare the statement |
|
| 66 | $this->addPreparedStatement($name, $this->getConnection()->prepare($statement)); |
|
| 67 | } |
|
| 68 | ||
| 69 | // pass the call to the parent method |
|
| 70 | return parent::execute($row, $name); |
|
| 71 | } |
|
| 72 | } |
|
| 73 | ||