public function homePageSalesEnding() { $i = 1; $categories = Mage::helper('catalog/category')->getStoreCategories(); foreach ($categories as $_category) { if ($_category->hasChildren()) { $_category->getId(); // category id if ($_category->getId() != 5) { //foreach($_category->getChildren() as $subcategory){ //$c = Mage::getModel('catalog/category')->load($subcategory->getId()); $subcategory = $_category->getChildren(); $child_id_explode = explode(",", $subcategory); foreach ($child_id_explode as $subcategory) { $c = Mage::getModel('catalog/category')->load($subcategory); if ($c->getIsActive()) { // check if category is active $twodays = strtotime(date('y-m-d H:G:00', strtotime("+2 days"))); $today = strtotime(date('y-m-d H:i:s')); if (!$c->getSale_start_date() == null) { $startdate = strtotime(date('y-m-d', strtotime($c->getSale_start_date())) . ' ' . $c->getSale_start_time() . ':00'); $enddate = strtotime(date('y-m-d', strtotime($c->getSale_end_date())) . ' ' . $c->getSale_end_time() . ':00'); if (timeBetweenNowAndDeadline($enddate) != 0 && $enddate < $twodays) { if ($i % 2 == 0) { echo '<article class="saleDetails fl noMargin">'; } else { echo '<article class="saleDetails fl">'; } echo '<a href="' . $c->getURL() . '"><span><img src="/media/catalog/category/' . $c->getImage() . '"></span></a>'; echo '<h3><a href="' . $c->getURL() . '">' . $c->getName() . '</a></h3>'; echo '<p>' . date('M jS \\a\\t g:ia', $enddate) . '</p>'; echo '</article>'; $i++; } } } } } } } }
public function menuToplevel() { $i = 1; $j = 1; $categories = Mage::helper('catalog/category')->getStoreCategories(); $twodays = strtotime(date('y-m-d H:G:00', strtotime("+2 days"))); $today = strtotime(date('y-m-d H:i:s')); foreach ($categories as $_category) { if ($_category->hasChildren()) { if ($_category->getId() != 5) { echo '<li><a href="' . $_category->getURL() . '">' . $_category->getName() . '</a>'; } else { echo '<li class="last"><a href="' . $_category->getURL() . '">' . $_category->getName() . '</a>'; } echo '<div><ul>'; $_category->getId(); // category id if ($_category->getId() != 5) { //foreach($_category->getChildren() as $subcategory){ //$c = Mage::getModel('catalog/category')->load($subcategory->getId()); $subcategory = $_category->getChildren(); $child_id_explode = explode(",", $subcategory); // Sales orders are arranging the Subcategories position wise. $subCategoriesSorted = array(); //We're going to make an array of the sub cats, with the array key being the position (set in the back end by dragging), then we can sort by key. foreach ($child_id_explode as $subCategoryId) { $cat = Mage::getModel('catalog/category')->load($subCategoryId); if ($cat->getIsActive()) { $subCategoriesSorted[$cat->getPosition()] = $subCategoryId; } } ksort($subCategoriesSorted); foreach ($subCategoriesSorted as $subcategory) { $c = Mage::getModel('catalog/category')->load($subcategory); if ($c->getIsActive()) { // check if category is active if (!$c->getSale_start_date() == null) { $startdate = strtotime(date('y-m-d', strtotime($c->getSale_start_date())) . ' ' . $c->getSale_start_time() . ':00'); $enddate = strtotime(date('y-m-d', strtotime($c->getSale_end_date())) . ' ' . $c->getSale_end_time() . ':00'); if (timeBetweenNowAndDeadline($enddate) != 0 && $enddate > $twodays && $startdate < $today) { if ($i == 1) { echo '<li class="navSectTitle">New Sales</li>'; echo '<li><a href="' . $c->getURL() . '">' . $c->getName() . '</a></li>'; } else { echo '<li><a href="' . $c->getURL() . '">' . $c->getName() . '</a></li>'; } $i++; } } } } $i = 1; echo '</ul><ul>'; //foreach($_category->getChildren() as $subcategory){ //$c = Mage::getModel('catalog/category')->load($subcategory->getId()); $subcategory = $_category->getChildren(); $child_id_explode = explode(",", $subcategory); // Sales orders are arranging the Subcategories position wise. $subCategoriesSorted = array(); //We're going to make an array of the sub cats, with the array key being the position (set in the back end by dragging), then we can sort by key. foreach ($child_id_explode as $subCategoryId) { $cat = Mage::getModel('catalog/category')->load($subCategoryId); if ($cat->getIsActive()) { $subCategoriesSorted[$cat->getPosition()] = $subCategoryId; } } ksort($subCategoriesSorted); foreach ($subCategoriesSorted as $subcategory) { $c = Mage::getModel('catalog/category')->load($subcategory); if ($c->getIsActive()) { // check if category is active if (!$c->getSale_start_date() == null) { $startdate = date('y-m-d', strtotime($c->getSale_start_date())) . ' ' . $c->getSale_start_time() . ':00'; $enddate = strtotime(date('y-m-d', strtotime($c->getSale_end_date())) . ' ' . $c->getSale_end_time() . ':00'); if (timeBetweenNowAndDeadline($enddate) != 0 && $enddate < $twodays && $startdate < $today) { if ($j == 1) { echo '<li class="navSectTitle">Ending Soon</li>'; echo '<li><a href="' . $c->getURL() . '">' . $c->getName() . '</a></li>'; } else { echo '<li><a href="' . $c->getURL() . '">' . $c->getName() . '</a></li>'; } $j++; } } } } } else { //foreach($_category->getChildren() as $subcategory){ //$c = Mage::getModel('catalog/category')->load($subcategory->getId()); $subcategory = $_category->getChildren(); $child_id_explode = explode(",", $subcategory); // Sales orders are arranging the Subcategories position wise. $subCategoriesSorted = array(); //We're going to make an array of the sub cats, with the array key being the position (set in the back end by dragging), then we can sort by key. foreach ($child_id_explode as $subCategoryId) { $cat = Mage::getModel('catalog/category')->load($subCategoryId); if ($cat->getIsActive()) { $subCategoriesSorted[$cat->getPosition()] = $subCategoryId; } } ksort($subCategoriesSorted); foreach ($subCategoriesSorted as $subcategory) { $c = Mage::getModel('catalog/category')->load($subcategory); if ($c->getIsActive()) { // check if category is active echo '<li><a href="' . $c->getURL() . '">' . $c->getName() . '</a></li>'; } } } $j = 1; echo '</ul></div></li>'; } } }