Exemple #1
0
 static function getTestEcommerceProduct($controller, $idx)
 {
     $product = self::getTestProduct($controller, $idx);
     $product['wish_count'] = $idx * 7 * 7;
     $product['options'] = array();
     $product['general_options'] = array();
     if ($idx % 2) {
         $product['options']['size'] = array('S', 'M', 'L', 'XL');
     }
     if ($idx != 5 && $idx != 8) {
         $product['options']['color'] = array('Red', 'Light Green', 'Blue');
     }
     $decorations = self::_getProductDecorations($controller);
     if (isset($decorations[$idx - 1])) {
         $decoration = Helper_URL::constructFid($decorations[$idx - 1]);
         $product['decoration'] = $decoration;
     }
     $product['is_backorder'] = $idx % 3 == 1;
     $product['stock'] = ($idx - 1) % 4 + 1;
     $product['sold_stock'] = ($idx - 1) % 20 * 7;
     $product['is_in_stock'] = !(bool) ($idx % 3 == 1);
     $product['variants'] = array('|Red' => 'available', '|Blue' => 'no_stock');
     $product['detailed_variants'] = array('|Red' => array('price' => 5000.5, 'stock' => 5), '|Blue' => array('price' => 1000.5, 'stock' => 0));
     if ($idx % 2) {
         $product['variants'] = array('S|Red' => 'no_stock', 'M|Red' => 'available', 'S|Light Green' => 'available', '|Blue' => 'no_stock');
         $product['detailed_variants'] = array('S|Red' => array('price' => 1000.5, 'stock' => 0), 'M|Red' => array('price' => 2000, 'stock' => 1000000), 'S|Light Green' => array('price' => 2000.5, 'stock' => 4), '|Blue' => array('price' => 10000, 'stock' => 0));
     }
     $product['prices_by_color'] = array('Red' => 20.5, 'Blue' => 3000, 'Pink' => 40);
     if ($idx == 7) {
         $product['options']['size'] = array('S', 'M', 'L', 'XL');
         unset($product['options']['color']);
         $product['variants'] = array('S|' => 'available', 'L|' => 'no_stock');
         $product['detailed_variants'] = array('S|' => array('price' => 3000.5, 'stock' => 3), 'L|' => array('price' => 1000.5, 'stock' => 0));
     }
     if ($idx == 4) {
         $product['variants'] = array();
         $product['detailed_variants'] = array();
     }
     $titles = array('Size', 'Color');
     foreach ($product['options'] as $key => $val) {
         $i = 0;
         if ($key == 'size') {
             $i = 1;
         } else {
             if ($key == 'color') {
                 $i = 2;
             }
         }
         $genkey = 'option' . $i;
         $genopt = array('title' => isset($titles[($i - 1) % 2]) ? $titles[($i - 1) % 2] : "Option {$i}", 'value' => "{$genkey}_value", 'options' => $val);
         $product['general_options'][$genkey] = $genopt;
         $i++;
     }
     return $product;
 }