Skip to content

Commit

Permalink
Add OneClick button to virtual product (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
rus-daniel authored and mehdichaouch committed May 29, 2018
1 parent 67a6e29 commit 954713e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/code/community/Oyst/OneClick/Model/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class Oyst_OneClick_Model_Catalog extends Mage_Core_Model_Abstract
Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
Mage_Catalog_Model_Product_Type::TYPE_GROUPED,
//Mage_Catalog_Model_Product_Type::TYPE_BUNDLE,
//Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL,
//Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE,
Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL,
Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE,
);

/**
Expand Down
24 changes: 24 additions & 0 deletions app/code/community/Oyst/OneClick/Model/OneClick/ApiWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,28 @@ public function getCartItems(&$dataFormated)
$dataFormated['products'] = Zend_Json::encode($products);
Mage::helper('oyst_oneclick')->log($dataFormated['products']);
}

/**
* Check if all products are materialized.
*
* @param $oystProducts
*
* @return bool
*/
private function productsAreMaterialized($oystProducts)
{
$productModel = Mage::getModel('catalog/product');
$materialised = true;

foreach ($oystProducts as $oystProduct) {
// @codingStandardsIgnoreLine
$product = $productModel->load($oystProduct->reference);

if (in_array($product->getTypeId(), array(Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL, Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE))) {
$materialised = false;
}
}

return $materialised;
}
}

0 comments on commit 954713e

Please sign in to comment.