public function getProducts() { if (!$this->_products) { $product = new Catalog_Model_Product(); $this->_products = $product->findByCategory($this->getId(), true); } return $this->_products; }
public function getProduct() { if (is_null($this->_product) and $id = $this->getRequest()->getParam('id')) { $product = new Catalog_Model_Product(); $product->find($id); $this->_product = $product; } return $this->_product; }
public function findAction() { if ($value_id = $this->getRequest()->getParam('value_id') and $set_meal_id = $this->getRequest()->getParam('set_meal_id')) { $set_meal = new Catalog_Model_Product(); $set_meal->find($set_meal_id); $option_value = $this->getCurrentOptionValue(); $data = array(); if ($set_meal->getData("type") == "menu") { $data = array("name" => $set_meal->getName(), "conditions" => $set_meal->getConditions(), "description" => $set_meal->getDescription(), "price" => $set_meal->getPrice() > 0 ? $set_meal->getFormattedPrice() : null, "picture" => $set_meal->getPictureUrl(), "social_sharing_active" => $option_value->getSocialSharingIsActive()); } $this->_sendHtml($data); } }
public function viewAction() { try { $product = new Catalog_Model_Product(); $product->find($this->getRequest()->getParam('product_id')); if (!$product->getId() or $product->getValueId() != $this->getCurrentOptionValue()->getId()) { throw new Exception($this->_('An error occurred while loading your product.')); } $option = $this->getCurrentOptionValue(); $this->loadPartials($this->getFullActionName('_') . '_l' . $this->_layout_id, false); $this->getLayout()->getPartial('content')->setCurrentProduct($product); $html = array('html' => $this->getLayout()->render(), 'title' => $option->getTabbarName()); if ($url = $option->getBackgroundImageUrl()) { $html['background_image_url'] = $url; } $html['use_homepage_background_image'] = (int) $option->getUseHomepageBackgroundImage() && !$option->getHasBackgroundImage(); $html = array_merge($html, array('next_button_title' => $this->_('Cart'), 'next_button_arrow_is_visible' => 1)); } catch (Exception $e) { $html = array('message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($html)); }
public function findallAction() { if ($value_id = $this->getRequest()->getParam('value_id')) { $data = array("collection" => array()); $menu = new Catalog_Model_Product(); $offset = $this->getRequest()->getParam('offset', 0); $menus = $menu->findAll(array('value_id' => $value_id, 'type' => 'menu'), array(), array("offset" => $offset, "limit" => Catalog_Model_Product::DISPLAYED_PER_PAGE)); foreach ($menus as $menu) { switch ($this->getCurrentOptionValue()->getLayoutId()) { case 2: case 3: $data["collection"][] = array("title" => $menu->getName(), "subtitle" => $menu->getFormattedPrice(), "picture" => $menu->getThumbnailUrl(), "url" => $this->getPath("catalog/mobile_setmeal_view", array("value_id" => $value_id, "set_meal_id" => $menu->getId()))); break; case 1: default: $data["collection"][] = array("title" => $menu->getName(), "subtitle" => $menu->getConditions(), "picture" => $menu->getThumbnailUrl(), "url" => $this->getPath("catalog/mobile_setmeal_view", array("value_id" => $value_id, "set_meal_id" => $menu->getId()))); break; } } $data["page_title"] = $this->getCurrentOptionValue()->getTabbarName(); $data["displayed_per_page"] = Catalog_Model_Product::DISPLAYED_PER_PAGE; $this->_sendHtml($data); } }
public function loadProducts() { $product = new Catalog_Model_Product(); $products = $product->findByCategory($this->getId()); foreach ($products as $product) { $this->_products[$product->getId()] = $product; } return $this; }
public function createDummyContents($option_value, $design, $category) { $option = new Application_Model_Option(); $option->find($option_value->getOptionId()); $dummy_content_xml = $this->_getDummyXml($design, $category); if ($option->getCode() == "catalog") { foreach ($dummy_content_xml->catalog->children() as $categories) { $this->unsData(); //check si la category existe sur cette app $category_data = array("name" => $categories->name, "value_id" => $option_value->getId()); $category_id = $this->find($category_data)->getCategoryId(); if (!$category_id) { $this->setName((string) $categories->name)->setValueId($option_value->getId())->save(); $category_id = $this->getId(); } foreach ($categories->products->children() as $product) { $product_model = new Catalog_Model_Product(); if ($product->attributes()->subcategory) { $sub_category_model = new Catalog_Model_Category(); //check si la sous category existe sur cette app $subcategory_data = array("name" => $product->attributes()->subcategory, "value_id" => $option_value->getId()); $sub_category_model->find($subcategory_data); if (!$sub_category_model->getCategoryId()) { $sub_category_model->setName($product->attributes()->subcategory)->setValueId($option_value->getId())->setParentId($category_id)->save(); $product_model->setCategoryId($sub_category_model->getId()); } else { $sub_category_model->setParentId($category_id)->save(); $product_model->setCategoryId($sub_category_model->getId()); } } else { $product_model->setCategoryId($category_id); } foreach ($product->content->children() as $key => $value) { $product_model->addData((string) $key, (string) $value); } if ($product->formats) { $format_option = array(); foreach ($product->formats->children() as $format) { foreach ($format as $key => $val) { $format_option[$format->getName()][(string) $key] = (string) $val; } } $product_model->setOption($format_option); } $product_model->setValueId($option_value->getId())->save(); } } } }
public function sortproductsAction() { if ($rows = $this->getRequest()->getParam('product')) { $html = array(); try { if (!$this->getCurrentOptionValue()) { throw new Exception('Une erreur est survenue lors de la sauvegarde.'); } $product = new Catalog_Model_Product(); $products = $product->findByValueId($this->getCurrentOptionValue()->getId()); $product_ids = array(); foreach ($products as $product) { $product_ids[] = $product->getId(); } foreach ($rows as $key => $row) { if (!in_array($row, $product_ids)) { throw new Exception($this->_('An error occurred while saving. One of your products could not be identified.')); } } $product->updatePosition($rows); $html = array('success' => 1); } catch (Exception $e) { $html = array('message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function deletepostAction() { $id = $this->getRequest()->getParam("id"); $html = ''; try { $menu = new Catalog_Model_Product(); $menu->find($id)->delete(); $html = array('menu_id' => $id, 'success' => 1, 'success_message' => $this->_('Set meal successfully deleted.'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } catch (Exception $e) { $html = array('message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($html)); }
public function findAction() { if ($value_id = $this->getRequest()->getParam('value_id') and $product_id = $this->getRequest()->getParam('product_id')) { $product = new Catalog_Model_Product(); $product->find($product_id); $option_value = $this->getCurrentOptionValue(); $data = array(); if ($product->getData("type") != "menu") { $format = array(); if ($product->getData("type") == "format") { foreach ($product->getType()->getOptions() as $option) { $format[] = array("id" => $option->getId(), "title" => $option->getTitle(), "price" => $option->getFormattedPrice()); } } $data = array("name" => $product->getName(), "conditions" => $product->getConditions(), "description" => $product->getDescription(), "price" => $product->getPrice() > 0 ? $product->getFormattedPrice() : null, "picture" => $product->getPictureUrl(), "formats" => $format, "social_sharing_active" => $option_value->getSocialSharingIsActive()); } $this->_sendHtml($data); } }