Skip to content

Commit

Permalink
Intial commit to see if these changes fix problems in Magento 1.5 wit…
Browse files Browse the repository at this point in the history
…h errors adding to cart not redirecting back to the right place
  • Loading branch information
Toasty committed Jun 17, 2011
1 parent d7830db commit c137e4b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
Expand Up @@ -23,4 +23,18 @@ public function isVisibleInSiteVisibility()
return parent::isVisibleInSiteVisibility();
}
}


public function getProductUrl($useSid = null)
{
if(is_callable(array($this->getTypeInstance(), 'hasConfigurableProductParentId'))
&& $this->getTypeInstance()->hasConfigurableProductParentId()) {

$confProdId = $this->getTypeInstance()->getConfigurableProductParentId();
return Mage::getModel('catalog/product')->load($confProdId)->getProductUrl();

} else {
return parent::getProductUrl($useSid);
}
}
}
Expand Up @@ -2,6 +2,26 @@
class OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Product_Type_Simple
extends Mage_Catalog_Model_Product_Type_Simple
{
#Later this should be refactored to live elsewhere probably,
#but it's ok here for the time being
private function getCpid()
{
$cpid = $this->getProduct()->getCustomOption('cpid');
if ($cpid) {
return $cpid;
}

$br = $this->getProduct()->getCustomOption('info_buyRequest');
if ($br) {
$brData = unserialize($br->getValue());
if(!empty($brData['cpid'])) {
return $brData['cpid'];
}
}

return false;
}

public function prepareForCart(Varien_Object $buyRequest, $product = null)
{
$product = $this->getProduct($product);
Expand All @@ -14,9 +34,13 @@ public function prepareForCart(Varien_Object $buyRequest, $product = null)

public function hasConfigurableProductParentId()
{
if ($this->getProduct()->getCustomOption('cpid')) {
return true;
}
return false;
$cpid = $this->getCpid();
Mage::log("cpid: ". $cpid);
return !empty($cpid);
}

public function getConfigurableProductParentId()
{
return $this->getCpid();
}
}

3 comments on commit c137e4b

@myforgedoteu
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me on 1.5.1
thanks.

@thomas-harding
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great on 1.9.2.4 too. Thanks!

@brb-elia
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the same thing on OrganicInternet_SimpleConfigurableProducts_Catalog_Model_Product_Type_Virtual

Please sign in to comment.