Ejemplo n.º 1
0
 public function testGetProduct()
 {
     $this->assertNotEmpty($this->_block->getProduct()->getId());
     $this->assertEquals($this->_product->getId(), $this->_block->getProduct()->getId());
     Mage::unregister('product');
     $this->_block->setProductId(1);
     $this->assertEquals($this->_product->getId(), $this->_block->getProduct()->getId());
 }
Ejemplo n.º 2
0
 public function getProduct()
 {
     if (!is_null($this->_product)) {
         return $this->_product;
     } elseif (!is_null($this->getData("product"))) {
         return $this->getData("product");
     }
     return parent::getProduct();
 }
Ejemplo n.º 3
0
 /**
  * Product view block, don't cache if rendered with cart item update
  *
  * @param Mage_Catalog_Block_Product_View $block
  */
 public function applyProductView(Mage_Catalog_Block_Product_View $block)
 {
     // The "messages" block is session-dependent, don't cache
     if (Mage::helper('cache')->responseHasMessages()) {
         $block->setData('cache_lifetime', null);
         return;
     }
     // Cart stuff is session-dependent
     $request = $block->getRequest();
     if ($request->getModuleName() == 'checkout' && $request->getControllerName() == 'cart' && $request->getActionName() == 'configure' && $request->getParam('id')) {
         $block->setData('cache_lifetime', null);
         return;
     }
     // Set cache tags
     $tags = array(Mage_Catalog_Model_Product::CACHE_TAG . '_' . $block->getProduct()->getId());
     $block->setData('cache_tags', $tags);
     // Set cache keys
     $keys = $this->_getBasicKeys($block);
     $_taxCalculator = Mage::getModel('tax/calculation');
     $_customer = Mage::getSingleton('customer/session')->getCustomer();
     $_product = $block->getProduct();
     $keys = array_merge($keys, array($_product->getId(), $_customer->getGroupId(), $_taxCalculator->getRate($_taxCalculator->getRateRequest()->setProductClassId($_product->getTaxClassId()))));
     $block->setData('cache_key', $this->_getCacheKey($keys, $block));
 }
 /** @return Mage_Catalog_Model_Product */
 function getProduct()
 {
     $product = parent::getProduct();
     $this->applyName($product);
     return $product;
 }
Ejemplo n.º 5
0
 /**
  * return an array of the earn rules using the current session (date,wid,gid,pid)
  * This should be changed to return all rules for the product ignoring just the group id
  *
  * @return array() 
  */
 public function getEarnRules()
 {
     $product = Mage::getModel('rewards/catalog_product')->load(parent::getProduct()->getId());
     return $product->getDistriRules();
 }
Ejemplo n.º 6
0
 /**
  * Collects list of objects in product list
  *
  * @param Mage_Catalog_Block_Product_View $object
  * @return Mage_Catalog_Model_Product[]
  */
 public function collect($object)
 {
     return array($object->getProduct());
 }
Ejemplo n.º 7
0
 /**
  * @param string $html
  * @param Mage_Catalog_Block_Product_View $block
  * @return string
  */
 private function _processCatalogProductView($html, $block)
 {
     $helper = $this->_getHelper();
     $product = $block->getProduct();
     /** @var $processor Mageplace_Callforprice_Model_Htmlprocessor_Interface */
     $processor = Mage::getModel('mageplace_callforprice/htmlprocessor_factory')->createProcessor();
     $processor->load($html);
     if ($helper->isGlobalEnabled() || $helper->isEnabledForProduct($product)) {
         $processor->replace($helper->getCssSelector('product_view_price'), $helper->prepareReplacement());
         $removeBlockSelectors = array('product_view_qty', 'product_view_qtylabel', 'product_view_addtocart', 'product_view_tier_price', 'product_view_price_notice', 'product_view_price_bundle');
         foreach ($removeBlockSelectors as $blockSelector) {
             $processor->remove($helper->getCssSelector($blockSelector));
         }
         $html = $processor->getHtml();
     }
     return $html;
 }