static function _ecommerceProductToArr($controller, $obj) { $arr = self::_basicProductToArr($controller, $obj); if (!$obj instanceof EcommerceProduct) { return $arr; } $tempSimpleProducts = Helper_Krco::getSimpleProductsByAggregatorId($controller, $obj->getId()); $simpleProducts = array(); foreach ($tempSimpleProducts as $simProd) { $newSimProd = Helper_Cart::_combineSimpleFromAggregator($simProd, $obj); $simpleProducts[] = $newSimProd; } $arr['decoration'] = $obj->getRibbon(); $arr['wish_count'] = (int) $obj->getWishCount(); $arr['options'] = $controller->_getProductOptions($obj); $arr['general_options'] = $controller->_getProductGeneralOptions($arr['options']); $arr['is_backorder'] = Helper_Structure::_getAttrFromObj('IsAllowBackorder', $obj); $arr['variants'] = $controller->_getProductVariants($obj, $simpleProducts); $arr['detailed_variants'] = $controller->_getProductVariants($obj, $simpleProducts, TRUE); $arr['prices_by_color'] = $controller->_getPricesByColor($obj, $simpleProducts); $arr['advanced_pricing_rules'] = json_decode($obj->getAdvancedPricingRule(), TRUE); $arr['size'] = $obj->getAttribute1(); $arr['color'] = $obj->getAttribute2(); //$arr['material'] = $obj->getAttribute3(); $options = $controller->getObjKrcoConfig('options', 'products'); if (is_array($options)) { $idx = 3; $defKeys = Helper_Krco::getDefaultProductOptionKeys(); foreach ($options as $key => $opt) { if (in_array($key, $defKeys)) { continue; } $getAttr = "getAttribute{$idx}"; $arr[$key] = $obj->{$getAttr}(); $idx++; } } return $arr; }
static function getTestProduct($controller, $idx) { $short_description = Helper_ViewTest::getLoremIpsumP(1) . "\n" . Helper_ViewTest::getLoremIpsumP(1); if ($idx % 2) { $short_description = "<p>Very short description.</p>\n"; } $description = Helper_ViewTest::getLoremIpsumP(2) . "\n" . Helper_ViewTest::getLoremIpsumP(1); if ($idx > 3) { $description = Helper_ViewTest::getLoremIpsumP(1); } $attachment = "http://attachment{$idx}"; $product = array('id' => $idx, 'fid' => "product-{$idx}", 'product_code' => "ABC{$idx}", 'title' => "Product {$idx}" . ($idx % 2 ? " Long Long Very Long Name" : ''), 'short_description' => $short_description, 'description' => $description, 'brand' => "Brand {$idx}", 'label' => "Category " . (($idx - 1) % 3 + 1), 'label_fid' => "parent/category" . (($idx - 1) % 3 + 1), 'specification' => self::_getTestProductSpecification(), 'link' => "http://product{$idx}", 'price_raw' => $idx == 16 ? 0 : $idx * 500, 'is_new' => !(bool) ($idx % 3), 'is_featured' => !(bool) ($idx % 2), 'size' => "Size {$idx}", 'color' => "Color {$idx}", 'images' => array($controller->resource_url . "/images/test/product_{$idx}a.jpg", $controller->resource_url . '/images/test/product_b.jpg', $controller->resource_url . '/images/test/product_a.jpg', $controller->resource_url . '/images/test/product_b.jpg', $controller->resource_url . '/images/test/product_a.jpg', $controller->resource_url . '/images/test/product_b.jpg'), 'detailed_images' => self::_getTestDetailedImages($controller, 12)); if ($idx == 8) { $product['label'] = 'Backorder'; } if (!($idx % 2)) { $product['images'] = array($controller->resource_url . "/images/test/product_{$idx}a.jpg", $controller->resource_url . '/images/test/product_b.jpg'); $product['detailed_images'] = self::_getTestDetailedImages($controller, 4); } if ($idx == 6) { $product['images'] = array(); $product['detailed_images'] = array(); } if ($idx % 2) { $product['attachment'] = $attachment; } if (isset($controller->krcoFunctions) && method_exists($controller->krcoFunctions, 'appendProduct')) { $controller->krcoFunctions->appendProduct($idx, $product); } $options = $controller->getObjKrcoConfig('options', 'products'); if (is_array($options)) { $defKeys = Helper_Krco::getDefaultProductOptionKeys(); foreach ($options as $key => $opt) { if (!in_array($key, $defKeys)) { $product[$key] = "{$key} {$idx}"; } } } $product = array_merge($product, Helper_ViewTest::getAdditionalTestFields($controller, 'products', $idx)); if ($idx % 2) { //$product['usual_price'] = '$ ' . ($idx*500+50); $product['usual_price_raw'] = $idx * 500 + 50; $product['sale_expiry_timestamp'] = $idx * 86400; } return $product; }