| Conditions | 4 |
| Paths | 5 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | public function up() |
||
| 32 | { |
||
| 33 | $site = $this->context()->locale()->getSiteItem()->getCode(); |
||
|
|
|||
| 34 | $this->info( sprintf( 'Adding default attribute data for site "%1$s"', $site ), 'vv' ); |
||
| 35 | |||
| 36 | $ds = DIRECTORY_SEPARATOR; |
||
| 37 | $path = __DIR__ . $ds . 'default' . $ds . 'data' . $ds . 'attribute.php'; |
||
| 38 | |||
| 39 | if( ( $data = include( $path ) ) == false ) { |
||
| 40 | throw new \RuntimeException( sprintf( 'No file "%1$s" found for default codes', $path ) ); |
||
| 41 | } |
||
| 42 | |||
| 43 | $manager = \Aimeos\MShop::create( $this->context(), 'attribute' ); |
||
| 44 | $item = $manager->create(); |
||
| 45 | |||
| 46 | foreach( $data as $dataset ) |
||
| 47 | { |
||
| 48 | try |
||
| 49 | { |
||
| 50 | $item = $item->setId( null )->fromArray( $dataset ); |
||
| 51 | $manager->save( $item ); |
||
| 52 | } |
||
| 53 | catch( \Exception $e ) { ; } // if attribute was already available |
||
| 54 | } |
||
| 57 |