Version Notes
- NEW: Handle bundle products
- FIX: Handling of multiple currencies
Download this release
Release Info
| Developer | Algolia Team |
| Extension | algoliasearch |
| Version | 1.4.4 |
| Comparing to | |
| See all releases | |
Code changes from version 1.4.3 to 1.4.4
- app/code/community/Algolia/Algoliasearch/Helper/Data.php +1 -1
- app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php +67 -27
- app/code/community/Algolia/Algoliasearch/etc/system.xml +1 -1
- app/design/frontend/base/default/template/algoliasearch/topsearch.phtml +13 -0
- package.xml +6 -8
app/code/community/Algolia/Algoliasearch/Helper/Data.php
CHANGED
|
@@ -23,7 +23,7 @@ class Algolia_Algoliasearch_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 23 |
|
| 24 |
public function __construct()
|
| 25 |
{
|
| 26 |
-
\AlgoliaSearch\Version::$custom_value = " Magento (1.4.
|
| 27 |
|
| 28 |
$this->algolia_helper = Mage::helper('algoliasearch/algoliahelper');
|
| 29 |
|
| 23 |
|
| 24 |
public function __construct()
|
| 25 |
{
|
| 26 |
+
\AlgoliaSearch\Version::$custom_value = " Magento (1.4.4)";
|
| 27 |
|
| 28 |
$this->algolia_helper = Mage::helper('algoliasearch/algoliahelper');
|
| 29 |
|
app/code/community/Algolia/Algoliasearch/Helper/Entity/Producthelper.php
CHANGED
|
@@ -232,8 +232,8 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 232 |
$customData['special_price'][$key] = (double) $special_price;
|
| 233 |
$customData['special_price_with_tax'][$key] = (double) Mage::helper('tax')->getPrice($product, $special_price, true, null, null, null, null, false);
|
| 234 |
|
| 235 |
-
$customData['special_price_formated'][$key] =
|
| 236 |
-
$customData['special_price_with_tax_formated'][$key] =
|
| 237 |
}
|
| 238 |
else
|
| 239 |
{
|
|
@@ -244,8 +244,8 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 244 |
$customData['special_price_with_tax'][$key] = '';
|
| 245 |
}
|
| 246 |
|
| 247 |
-
$customData['price_formated'][$key] =
|
| 248 |
-
$customData['price_with_tax_formated'][$key] =
|
| 249 |
}
|
| 250 |
|
| 251 |
public function getObject(Mage_Catalog_Model_Product $product)
|
|
@@ -371,44 +371,84 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 371 |
$sub_products = null;
|
| 372 |
$ids = null;
|
| 373 |
|
| 374 |
-
|
| 375 |
-
if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'grouped')
|
| 376 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
if ($product->getTypeId() == 'grouped')
|
| 378 |
$sub_products = $product->getTypeInstance(true)->getAssociatedProducts($product);
|
| 379 |
|
| 380 |
if ($product->getTypeId() == 'configurable')
|
| 381 |
$sub_products = $product->getTypeInstance(true)->getUsedProducts(null, $product);
|
| 382 |
|
| 383 |
-
$
|
| 384 |
-
|
| 385 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 386 |
|
| 387 |
$sub_products = $this->getProductCollectionQuery($product->getStoreId(), $ids, false)->load();
|
| 388 |
|
| 389 |
-
$
|
| 390 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 391 |
|
| 392 |
-
|
| 393 |
-
|
| 394 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
|
| 401 |
-
|
| 402 |
-
|
|
|
|
|
|
|
| 403 |
|
| 404 |
-
|
| 405 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
}
|
| 407 |
|
| 408 |
-
$customData['min_formated'] = Mage::helper('core')->formatPrice($min, false);
|
| 409 |
-
$customData['max_formated'] = Mage::helper('core')->formatPrice($max, false);
|
| 410 |
-
$customData['min_with_tax_formated'] = Mage::helper('core')->formatPrice($min_with_tax, false);
|
| 411 |
-
$customData['max_with_tax_formated'] = Mage::helper('core')->formatPrice($max_with_tax, false);
|
| 412 |
}
|
| 413 |
|
| 414 |
if (false === isset($defaultData['in_stock']))
|
|
@@ -433,7 +473,7 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 433 |
$customData['ordered_qty'] = (int) $ordered_qty;
|
| 434 |
$customData['stock_qty'] = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
|
| 435 |
|
| 436 |
-
if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'grouped')
|
| 437 |
{
|
| 438 |
$ordered_qty = 0;
|
| 439 |
$stock_qty = 0;
|
|
@@ -491,7 +531,7 @@ class Algolia_Algoliasearch_Helper_Entity_Producthelper extends Algolia_Algolias
|
|
| 491 |
if ($value === null)
|
| 492 |
{
|
| 493 |
/** Get values as array in children */
|
| 494 |
-
if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'grouped')
|
| 495 |
{
|
| 496 |
$values = array();
|
| 497 |
|
| 232 |
$customData['special_price'][$key] = (double) $special_price;
|
| 233 |
$customData['special_price_with_tax'][$key] = (double) Mage::helper('tax')->getPrice($product, $special_price, true, null, null, null, null, false);
|
| 234 |
|
| 235 |
+
$customData['special_price_formated'][$key] = $product->getStore()->formatPrice($customData['special_price'][$key], false);
|
| 236 |
+
$customData['special_price_with_tax_formated'][$key] = $product->getStore()->formatPrice($customData['special_price_with_tax'][$key], false);
|
| 237 |
}
|
| 238 |
else
|
| 239 |
{
|
| 244 |
$customData['special_price_with_tax'][$key] = '';
|
| 245 |
}
|
| 246 |
|
| 247 |
+
$customData['price_formated'][$key] = $product->getStore()->formatPrice($customData['price'][$key], false);
|
| 248 |
+
$customData['price_with_tax_formated'][$key] = $product->getStore()->formatPrice($customData['price_with_tax'][$key], false);
|
| 249 |
}
|
| 250 |
|
| 251 |
public function getObject(Mage_Catalog_Model_Product $product)
|
| 371 |
$sub_products = null;
|
| 372 |
$ids = null;
|
| 373 |
|
| 374 |
+
if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'grouped' || $product->getTypeId() == 'bundle')
|
|
|
|
| 375 |
{
|
| 376 |
+
$min = PHP_INT_MAX;
|
| 377 |
+
$max = 0;
|
| 378 |
+
|
| 379 |
+
$min_with_tax = PHP_INT_MAX;
|
| 380 |
+
$max_with_tax = 0;
|
| 381 |
+
|
| 382 |
+
if ($product->getTypeId() == 'bundle')
|
| 383 |
+
{
|
| 384 |
+
|
| 385 |
+
$_priceModel = $product->getPriceModel();
|
| 386 |
+
|
| 387 |
+
list($min, $max) = $_priceModel->getTotalPrices($product, null, null, false);
|
| 388 |
+
list($min_with_tax, $max_with_tax) = $_priceModel->getTotalPrices($product, null, true, false);
|
| 389 |
+
|
| 390 |
+
$ids = array();
|
| 391 |
+
|
| 392 |
+
$selection = $product->getTypeInstance(true)->getSelectionsCollection($product->getTypeInstance(true)->getOptionsIds($product), $product);
|
| 393 |
+
|
| 394 |
+
foreach($selection as $option)
|
| 395 |
+
$ids[] = $option->product_id;
|
| 396 |
+
}
|
| 397 |
+
|
| 398 |
if ($product->getTypeId() == 'grouped')
|
| 399 |
$sub_products = $product->getTypeInstance(true)->getAssociatedProducts($product);
|
| 400 |
|
| 401 |
if ($product->getTypeId() == 'configurable')
|
| 402 |
$sub_products = $product->getTypeInstance(true)->getUsedProducts(null, $product);
|
| 403 |
|
| 404 |
+
if ($product->getTypeId() == 'grouped' || $product->getTypeId() == 'configurable')
|
| 405 |
+
{
|
| 406 |
+
$ids = array_map(function ($product)
|
| 407 |
+
{
|
| 408 |
+
return $product->getId();
|
| 409 |
+
}, $sub_products);
|
| 410 |
+
}
|
| 411 |
|
| 412 |
$sub_products = $this->getProductCollectionQuery($product->getStoreId(), $ids, false)->load();
|
| 413 |
|
| 414 |
+
if ($product->getTypeId() == 'grouped' || $product->getTypeId() == 'configurable')
|
| 415 |
+
{
|
| 416 |
+
foreach ($sub_products as $sub_product)
|
| 417 |
+
{
|
| 418 |
+
$price = $sub_product->getPrice();
|
| 419 |
+
$price_with_tax = Mage::helper('tax')->getPrice($sub_product, $price, true, null, null, null, null, false);
|
| 420 |
|
| 421 |
+
$min = min($min, $price);
|
| 422 |
+
$max = max($max, $price);
|
| 423 |
|
| 424 |
+
$min_with_tax = min($min_with_tax, $price_with_tax);
|
| 425 |
+
$max_with_tax = max($max_with_tax, $price_with_tax);
|
| 426 |
+
}
|
| 427 |
+
}
|
| 428 |
|
| 429 |
+
$customData['min_formated'] = array();
|
| 430 |
+
$customData['max_formated'] = array();
|
| 431 |
+
$customData['min_with_tax_formated'] = array();
|
| 432 |
+
$customData['max_with_tax_formated'] = array();
|
| 433 |
|
| 434 |
+
$customData['min_formated']['default'] = $product->getStore()->formatPrice($min, false);
|
| 435 |
+
$customData['max_formated']['default'] = $product->getStore()->formatPrice($max, false);
|
| 436 |
+
$customData['min_with_tax_formated']['default'] = $product->getStore()->formatPrice($min_with_tax, false);
|
| 437 |
+
$customData['max_with_tax_formated']['default'] = $product->getStore()->formatPrice($max_with_tax, false);
|
| 438 |
|
| 439 |
+
if ($this->config->isCustomerGroupsEnabled($product->getStoreId()))
|
| 440 |
+
{
|
| 441 |
+
foreach ($groups = Mage::getModel('customer/group')->getCollection() as $group)
|
| 442 |
+
{
|
| 443 |
+
$group_id = (int)$group->getData('customer_group_id');
|
| 444 |
+
|
| 445 |
+
$customData['min_formated']['group_' . $group_id] = $product->getStore()->formatPrice($min, false);
|
| 446 |
+
$customData['max_formated']['group_' . $group_id] = $product->getStore()->formatPrice($max, false);
|
| 447 |
+
$customData['min_with_tax_formated']['group_' . $group_id] = $product->getStore()->formatPrice($min_with_tax, false);
|
| 448 |
+
$customData['max_with_tax_formated']['group_' . $group_id] = $product->getStore()->formatPrice($max_with_tax, false);
|
| 449 |
+
}
|
| 450 |
}
|
| 451 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
}
|
| 453 |
|
| 454 |
if (false === isset($defaultData['in_stock']))
|
| 473 |
$customData['ordered_qty'] = (int) $ordered_qty;
|
| 474 |
$customData['stock_qty'] = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
|
| 475 |
|
| 476 |
+
if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'grouped' || $product->getTypeId() == 'bundle')
|
| 477 |
{
|
| 478 |
$ordered_qty = 0;
|
| 479 |
$stock_qty = 0;
|
| 531 |
if ($value === null)
|
| 532 |
{
|
| 533 |
/** Get values as array in children */
|
| 534 |
+
if ($product->getTypeId() == 'configurable' || $product->getTypeId() == 'grouped' || $product->getTypeId() == 'bundle')
|
| 535 |
{
|
| 536 |
$values = array();
|
| 537 |
|
app/code/community/Algolia/Algoliasearch/etc/system.xml
CHANGED
|
@@ -4,7 +4,7 @@
|
|
| 4 |
<algoliasearch translate="label" module="algoliasearch">
|
| 5 |
<label>
|
| 6 |
<