Example #1
0
	/**
	 * Получение форматированного списка товаров корзины
	 * @param Array  $data - данные корзины
	 * @param Template $template - шаблон для элементов товаров
	 * @return String - список товаров
	 */
	public function format_list($template)
	{
		$data = &$this->data;
		if ($data === false)
			return;

		$product_list = "";
		reset($data);
		while (list($product_id, $sizes) = each($data))
		{
			$product = $this->objects->Products->get($product_id);
			if ($product === false)
				continue;

			$child_category = $this->objects->Categories->get($product['child_id']);
			$parent_category = $this->objects->Categories->get($product['parent_id']);
		
			while (list($size, $count) = each($sizes))
			{
				$template->clear();
				$product['url_name'] = str_replace(" ", "+", $product['name']);
				$product['count'] = $count;
				$product['size_'.$size] = $size;
				$product['image_small'] = $this->Products->get_image_small($product['id']);
				$template->bind_params($product);

				if ($parent_category !== false)
					$template->bind_params($parent_category->get_data(), "Parent_category::");
				if ($child_category !== false)
					$template->bind_params($child_category->get_data(), "Child_category::");

				$caregory_parent = $this->Categories->get($product['parent_id']);
				$template->{$caregory_parent->name} = true;

				$product_list .= (string) $template;
			}
		}

		return $product_list;
	}