function testSelection() { $vehicle = $this->createMMY(self::MAKE, self::MODEL, self::YEAR); $request = $this->getRequest($vehicle->toValueArray()); $helper = new Elite_Vaf_Helper_Data(); $helper->setRequest($request); $vehicle = $helper->vehicleSelection(); $this->assertMMYTitlesEquals(self::MAKE, self::MODEL, self::YEAR, $vehicle); }
function execute() { $schema = new Elite_Vaf_Model_Schema(); $leafLevel = Elite_Vaf_Helper_Data::getInstance()->getLeafLevel(); $ajax = new Elite_Vaf_Model_Ajax(); return $ajax->execute($schema); }
function run() { $schema = new Elite_Vaf_Model_Schema(); $db = Elite_Vaf_Helper_Data::getInstance()->getReadAdapter(); $db->query('ALTER TABLE `elite_product_servicecode` DROP PRIMARY KEY '); $db->query('ALTER TABLE `elite_product_servicecode` ADD PRIMARY KEY ( `product_id` , `service_code` , `category1_id` , `category2_id` , `category3_id` , `category4_id` , `illustration_id` , `callout` ) '); }
function listAction() { $helper = Elite_Vaf_Helper_Data::getInstance(); $helper->setRequest($this->getRequest()); $helper->storeFitInSession(); if (!$helper->getFit() || !$helper->getProductIds()) { return $this->redirectToHomePage(); } $this->myLoadLayout(); switch (Elite_Vaf_Helper_Data::getInstance()->getConfig()->homepagesearch->mode) { case 'grid': // set in layout.xml break; default: case 'group': // unset the grid block added from layout.xml $this->getLayout()->getBlock('content')->unsetChild('vaf_products'); $block = $this->createBlock('vaf/product_result_group', 'vaf_products'); $this->appendBlock($block); break; case 'category': // unset the grid block added from layout.xml $this->getLayout()->getBlock('content')->unsetChild('vaf_products'); $block = $this->createBlock('vaf/product_result_group2', 'vaf_products'); $this->appendBlock($block); break; case 'group3': // unset the grid block added from layout.xml $this->getLayout()->getBlock('content')->unsetChild('vaf_products'); $block = $this->createBlock('vaf/product_result_group3', 'vaf_products'); $this->appendBlock($block); break; } $this->renderLayout(); }
function getConfig() { if (!$this->config instanceof Zend_Config) { $this->config = Elite_Vaf_Helper_Data::getInstance()->getConfig(); } return $this->config; }
/** * I know its crap, but Magento sucks. * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */ function getProductCollection() { if (isset($this->_productCollections[$this->getCurrentCategory()->getId()])) { $collection = $this->_productCollections[$this->getCurrentCategory()->getId()]; } else { $ids = Elite_Vaf_Helper_Data::getInstance()->getProductIds(); if (Mage::helper('catalogSearch')->getEscapedQueryText() && Mage::getStoreConfig('catalog/search/filtering', Mage::app()->getStore()->getStoreId())) { $collection = Mage::getResourceModel('catalogsearch/fulltext_collection')->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->addSearchFilter(Mage::helper('catalogSearch')->getEscapedQueryText())->addIdFilter($ids)->setStore(Mage::app()->getStore())->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addStoreFilter()->addUrlRewrite(); Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); // Comment out following line for work-around for: // 0000295: Group View not Displaying products, but products show in browsing Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); } elseif (!Mage::helper('catalogSearch')->getEscapedQueryText()) { $collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())->setStore(Mage::app()->getStore())->addMinimalPrice()->addFinalPrice()->addTaxPercents()->addStoreFilter()->addUrlRewrite(); if ($ids) { $collection->addIdFilter($ids); } Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($collection); // Comment out following line for work-around for: // 0000295: Group View not Displaying products, but products show in browsing Mage::getSingleton('catalog/product_visibility')->addVisibleInSearchFilterToCollection($collection); } else { $collection = Mage::getResourceModel('catalogsearch/fulltext_collection'); $this->prepareProductCollection($collection); } $this->_productCollections[$this->getCurrentCategory()->getId()] = $collection; } return $collection; }
function doSetUp() { $this->switchSchema('make,model,year'); $this->expectedDefinition = $this->createMMY(); $this->setRequestParams($this->expectedDefinition->toValueArray()); $this->sitemap = new Elite_Vafsitemap_Model_Sitemap_Product_Sub(Elite_Vaf_Helper_Data::getInstance()->getConfig()); }
function testDefinitionsMMY() { $sitemap = new Elite_Vafsitemap_Model_Sitemap_Vehicle(Elite_Vaf_Helper_Data::getInstance()->getConfig()); $vehicles = $sitemap->getDefinitions(10); $this->assertTrue($vehicles[0] instanceof VF_Vehicle); $this->assertNotEquals(0, (int) $vehicles[0]->getLevel('year')->getId()); }
function run() { $schema = new VF_Schema(); $db = Elite_Vaf_Helper_Data::getInstance()->getReadAdapter(); $db->query('ALTER TABLE `elite_mapping` ADD `price` FLOAT NOT NULL '); $db->query('ALTER TABLE `elite_import` ADD `price` FLOAT NOT NULL '); }
function run() { $schema = new VF_Schema(); $db = Elite_Vaf_Helper_Data::getInstance()->getReadAdapter(); $db->query('DROP TABLE elite_import'); $db->query(' CREATE TABLE IF NOT EXISTS `elite_import` ( `id` int(255) NOT NULL AUTO_INCREMENT, `make` varchar(255) NOT NULL, `make_id` int(50) NOT NULL, `model` varchar(255) NOT NULL, `model_id` int(50) NOT NULL, `year` varchar(255) NOT NULL, `year_id` int(50) NOT NULL, `sku` varchar(255) DEFAULT NULL, `product_id` int(255) DEFAULT NULL, `universal` int(1) DEFAULT \'0\', `existing` int(1) NOT NULL, `line` int(255) NOT NULL, `mapping_id` int(255) NOT NULL, `note_message` varchar(255) NOT NULL, `notes` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;'); }
function testCount1() { $sitemap = new Elite_Vafsitemap_Model_Sitemap_Vehicle(Elite_Vaf_Helper_Data::getInstance()->getConfig()); $vehicle = $this->createMMTC(); $this->insertMappingMMTC($vehicle); $this->assertEquals(1, $sitemap->vehicleCount()); }
function indexAction() { if (!Elite_Vaf_Helper_Data::getInstance()->getConfig()->seo->htmlSitemap) { return; } $this->loadLayoutAndBlock(); }
function getSelections() { $startTime = time(); $vehicle = Elite_Vaf_Helper_Data::getInstance()->getFit(); if (Mage::app()->getStore()->isAdmin()) { return $this->getData('selections'); } if (!$this->superProductFits($vehicle)) { return $this->getData('selections'); } $selections = $this->getData('selections'); if (!$selections) { return; } if ($vehicle && $vehicle->getLeafValue()) { $productIds = Elite_Vaf_Helper_Data::getInstance()->getProductIds(); $return = array(); foreach ($selections as $product) { if (in_array($product->getId(), $productIds)) { array_push($return, $product); } } return $return; } $endTime = time(); var_dump($endTime - $startTime); exit; return $selections; }
function run() { $schema = new VF_Schema(); $db = Elite_Vaf_Helper_Data::getInstance()->getReadAdapter(); foreach ($schema->getLevels() as $level) { $db->query('ALTER TABLE `elite_mapping` ADD INDEX ( `entity_id` ) ;'); } }
function testShouldClearFromSession() { $flexibleSearch = $this->flexibleWheeladapterSearch(array('wheel_lug_count' => '5')); Elite_Vaf_Helper_Data::getInstance()->storeFitInSession(); $flexibleSearch = $this->flexibleWheeladapterSearch(array('wheel_lug_count' => '0')); Elite_Vaf_Helper_Data::getInstance()->storeFitInSession(); $this->assertNull($this->flexibleWheeladapterSearch()->wheelSideLugCount(), 'should clear wheel side lug count from session'); }
function testShouldClearFromSession() { $flexibleSearch = $this->flexibleWheelSearch(array('lug_count' => '5')); Elite_Vaf_Helper_Data::getInstance()->storeFitInSession(); $flexibleSearch = $this->flexibleWheelSearch(array('lug_count' => '0')); Elite_Vaf_Helper_Data::getInstance()->storeFitInSession(); $this->assertEquals(0, $this->flexibleWheelSearch()->lugCount(), 'should clear lug count from session'); }
function testShouldClearFromSession() { $flexibleSearch = $this->flexibleWheelSearch(array('stud_spread' => '5')); Elite_Vaf_Helper_Data::getInstance()->storeFitInSession(); $flexibleSearch = $this->flexibleWheelSearch(array('stud_spread' => '0')); Elite_Vaf_Helper_Data::getInstance()->storeFitInSession(); $this->assertEquals(0, $this->flexibleWheelSearch()->studSpread(), 'should clear stud spread from session'); }
function testShouldClearFromSession() { $flexibleSearch = $this->flexibleTireSearch(array('section_width' => '205', 'aspect_ratio' => '55', 'diameter' => '16')); Elite_Vaf_Helper_Data::getInstance()->storeFitInSession(); $flexibleSearch = $this->flexibleTireSearch(array('section_width' => '0', 'aspect_ratio' => '0', 'diameter' => '0')); Elite_Vaf_Helper_Data::getInstance()->storeFitInSession(); $this->assertNull($this->flexibleTireSearch()->aspectRatio(), 'should clear aspect ratio from session'); }
function testShouldClearFromSession() { $flexibleSearch = $this->flexibleWheeladapterSearch(array('wheel_stud_spread' => '114.3')); Elite_Vaf_Helper_Data::getInstance()->storeFitInSession(); $flexibleSearch = $this->flexibleWheeladapterSearch(array('wheel_stud_spread' => '0')); Elite_Vaf_Helper_Data::getInstance()->storeFitInSession(); $this->assertNull($this->flexibleWheeladapterSearch()->wheelSideStudSpread(), 'should clear wheel side stud spread from session'); }
function run() { $schema = new VF_Schema(); $db = Elite_Vaf_Helper_Data::getInstance()->getReadAdapter(); foreach ($schema->getLevels() as $level) { $db->query('ALTER TABLE `elite_level_' . str_replace(' ', '_', $level) . '` ADD INDEX ( `title` ) '); } }
function testShouldClearVehicleSelection() { $vehicle = $this->createVehicle(array('make' => 'Honda', 'model' => 'Civic', 'year' => '2000')); $this->setRequestParams($vehicle->toValueArray()); $this->assertEquals($vehicle->toValueArray(), Elite_Vaf_Helper_Data::getInstance()->vehicleSelection()->toValueArray(), 'should first select a vehicle'); $this->setRequestParams(array('lug_count' => '5', 'stud_spread' => '114.3')); Elite_Vaf_Helper_Data::getInstance()->flexibleSearch()->doGetProductIds(); $this->assertNull(Elite_Vaf_Helper_Data::getInstance()->vehicleSelection()->getFirstVehicle(), 'should clear vehicle when searching on a wheel size'); }
function run() { $schema = new VF_Schema(); $db = Elite_Vaf_Helper_Data::getInstance()->getReadAdapter(); foreach ($schema->getLevels() as $level) { $db->query('ALTER TABLE `elite_product_wheel` ADD `offset` FLOAT NOT NULL '); $db->query('ALTER TABLE `elite_definition_wheel` ADD `offset` FLOAT NOT NULL '); } }
function testDeletingFits() { // create product & a fit $vehicle = $this->createMMY(); $fit_id = $this->insertMappingMMY($vehicle, self::PRODUCT_ID); $product = $this->getProduct(self::PRODUCT_ID); $request = $this->getRequest(array('vaf-delete' => array('year-' . $fit_id))); // mock up an event and pass it to the SUT observer $event = $this->getMock('myEvent'); $event->expects($this->any())->method('getControllerAction')->will($this->returnValue($this->getController($request))); Mage::register('current_product', $product); $observer = new Elite_Vaf_Model_Observer_Test(); $observer->catalogProductEditAction($event); $request = $this->getRequest(array('make' => $vehicle->getLevel('make')->getId(), 'model' => $vehicle->getLevel('model')->getId(), 'year' => $vehicle->getLevel('year')->getId())); $helper = new Elite_Vaf_Helper_Data(); $helper->setRequest($request); $this->assertEquals(array(0), $helper->getProductIds(), 'deleting fitments should result in there being no fitments'); }
function testDefinitions() { $sitemap = new Elite_Vafsitemap_Model_Sitemap_Vehicle(Elite_Vaf_Helper_Data::getInstance()->getConfig()); $vehicle = $this->createMMTC(); $this->insertMappingMMTC($vehicle); $vehicles = $sitemap->getDefinitions(); $this->assertTrue($vehicles[0] instanceof VF_Vehicle); $this->assertNotEquals(0, (int) $vehicles[0]->getLevel('chassis')->getId()); }
function testWhenRewritesDisabled_ShouldNotRewriteTitle2() { $config = new Zend_Config(array('seo' => array('rewriteProductName' => false))); $product = $this->getProduct2($config); $product->addVafFit($this->vehicle->toValueArray()); $this->setRequestParams($this->vehicle->toValueArray()); $product->setCurrentlySelectedFit(Elite_Vaf_Helper_Data::getInstance()->vehicleSelection()); $this->assertEquals('Widget', $product->getName(), 'when rewrites disabled, should not rewrite title'); }
function testShouldClearVehicleSelection() { $vehicle = $this->createVehicle(array('make' => 'Honda', 'model' => 'Civic', 'year' => '2000')); $this->setRequestParams($vehicle->toValueArray()); $this->assertEquals($vehicle->toValueArray(), Elite_Vaf_Helper_Data::getInstance()->vehicleSelection()->toValueArray(), 'should first select a vehicle'); $this->setRequestParams(array('section_width' => '205', 'aspect_ratio' => '55', 'diameter' => '16')); Elite_Vaf_Helper_Data::getInstance()->flexibleSearch()->doGetProductIds(); $this->assertNull(Elite_Vaf_Helper_Data::getInstance()->vehicleSelection()->getFirstVehicle(), 'should clear vehicle when searching on a tire size'); }
function doProduct($product) { $sitemap = new Elite_Vafsitemap_Model_Sitemap_Vehicle(Elite_Vaf_Helper_Data::getInstance()->getConfig()); $vehicles = $sitemap->getDefinitions(null, null, $product->getId()); foreach ($vehicles as $vehicle) { $product->setCurrentlySelectedFit($vehicle); fwrite($this->stream, $this->row($product, $vehicle)); } }
/** Magento uses the "handle" of this action to load the block where the code lives */ function indexAction() { if (!Elite_Vaf_Helper_Data::getInstance()->getConfig()->seo->htmlSitemap) { return; } $this->loadLayout(); $this->_initLayoutMessages('checkout/session'); $this->_initLayoutMessages('tag/session'); $this->renderLayout(); }
function run() { $schema = new VF_Schema(); $db = Elite_Vaf_Helper_Data::getInstance()->getReadAdapter(); foreach ($schema->getLevels() as $level) { $old = 'elite_' . $level; $new = 'elite_level_' . $level; $db->query(sprintf("RENAME TABLE %s TO %s", $old, $new)); } }
function getProductRows() { $query = Elite_Vaf_Helper_Data::getInstance()->getReadAdapter()->select()->from($this->getProductTable(), array('entity_id', 'sku')); $rs = $query->query(); $ids = array(); while ($productRow = $rs->fetch()) { array_push($ids, $productRow); } return $ids; }