Skip to content

Commit

Permalink
Merge pull request #30 from magmodules/1.6.13
Browse files Browse the repository at this point in the history
1.6.13
  • Loading branch information
Marvin-Magmodules authored May 19, 2020
2 parents 90b9a2d + 32705eb commit 23bb802
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 10 deletions.
25 changes: 19 additions & 6 deletions app/code/community/Magmodules/Channable/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ public function getAttributeValue($field, $product, $config, $actions = '', $par
public function getProductUrl($product, $config, $parent, $parentAttributes)
{
$url = '';
$parent = !empty($config['field']['product_url']['parent']) ? $parent : null;

if (!empty($parent)) {
if ($parent->getRequestPath()) {
$url = Mage::helper('core')->escapeHtml(trim($config['website_url'] . $parent->getRequestPath()));
Expand Down Expand Up @@ -614,6 +616,7 @@ public function getProductPrice($product, $config)
if ($groupedPriceType == 'total') {
$price = $totalPrice;
$finalPrice = $totalPrice;
$maxPrice = max($finalPrice, $maxPrice);
}
break;
case 'bundle':
Expand Down Expand Up @@ -710,18 +713,21 @@ public function getProductPrice($product, $config)
public function getGroupedPrices($product, $config)
{
$prices = array();
$totalPrice = 0;

$_associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
foreach ($_associatedProducts as $_item) {
$priceAssociated = $this->processPrice($_item, $_item->getFinalPrice(), $config);
if ($priceAssociated > 0) {
$prices[] = $priceAssociated;
$totalPrice += $priceAssociated * $_item->getQty();
}
}

return array(
'min_price' => min($prices),
'max_price' => max($prices),
'total_price' => array_sum($prices)
'total_price' => $totalPrice > 0 ? $totalPrice : min($prices)
);
}

Expand Down Expand Up @@ -1237,6 +1243,16 @@ public function getTaxUsage($config)
*/
public function addAttributeData($attributes, $config = array())
{
$confAttributes = array();
if (!empty($config['conf_enabled'])) {
if (!empty($config['conf_fields'])) {
$confAttributes = explode(',', $config['conf_fields']);
}
if (!empty($config['configurable_link'])) {
$confAttributes[] = 'product_url';
}
}

foreach ($attributes as $key => $attribute) {
$type = (!empty($attribute['type']) ? $attribute['type'] : '');
$action = (!empty($attribute['action']) ? $attribute['action'] : '');
Expand All @@ -1257,11 +1273,8 @@ public function addAttributeData($attributes, $config = array())
$type = 'float';
}

if (!empty($config['conf_fields'])) {
$confAttributes = explode(',', $config['conf_fields']);
if (in_array($key, $confAttributes)) {
$parent = '1';
}
if (in_array($key, $confAttributes)) {
$parent = '1';
}

$attributes[$key] = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function toOptionArray()
if (!$this->options) {
$storeId = Mage::helper('channable')->getStoreIdConfig();
$attributes = Mage::getModel("channable/channable")->getFeedAttributes($storeId, 'config');
$attributesSkip = array('id', 'parent_id', 'price', 'availability', 'is_in_stock', 'qty', 'status', 'visibility');
$attributesSkip = $this->_getSkippedAttributes();
$att = array();
foreach ($attributes as $key => $attribute) {
if (!in_array($key, $attributesSkip) && !empty($key)) {
Expand All @@ -51,4 +51,23 @@ public function toOptionArray()

return $this->options;
}

/**
* @return array
*/
protected function _getSkippedAttributes()
{
return array(
'id',
'parent_id',
'price',
'availability',
'is_in_stock',
'qty',
'status',
'visibility',
'product_url'
);
}

}
25 changes: 25 additions & 0 deletions app/code/community/Magmodules/Channable/Model/Channable.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ public function getFeedConfig($storeId, $type = 'xml')
$config['conf_enabled'] = $this->helper->getConfigData('data/conf_enabled', $storeId);
$config['conf_fields'] = $this->helper->getConfigData('data/conf_fields', $storeId);
$config['stock_bundle'] = $this->helper->getConfigData('data/stock_bundle', $storeId);
$config['configurable_link'] = $this->helper->getConfigData('data/configurable_link', $storeId);
$config['conf_switch_urls'] = $this->helper->getConfigData('data/conf_switch_urls', $storeId);
$config['price_grouped'] = $this->helper->getConfigData('data/grouped_price', $storeId);
$config['simple_price'] = $this->helper->getConfigData('data/simple_price', $storeId);
$config['stock_manage'] = Mage::getStoreConfig('cataloginventory/item_options/manage_stock');
$config['use_qty_increments'] = Mage::getStoreConfig('cataloginventory/item_options/enable_qty_increments');
Expand Down Expand Up @@ -199,9 +201,32 @@ public function getFeedConfig($storeId, $type = 'xml')
$config['field'] = $this->getFeedAttributes($storeId, $type, $config);
$config['parent_att'] = $this->getParentAttributeSelection($config['field']);

// Convert prices form base currency to default currency
if ($this->helper->getConfigData('advanced/shipping_convert_prices', $storeId)) {
foreach ($config['shipping_prices'] as &$shipping_price) {
if ($config['shipping_method'] !== 'weight') {
$shipping_price['price_from'] = $this->convertToCurrency($shipping_price['price_from'], $config['base_currency_code'], $config['currency']);
$shipping_price['price_to'] = $this->convertToCurrency($shipping_price['price_to'], $config['base_currency_code'], $config['currency']);
}
$shipping_price['cost'] = $this->convertToCurrency($shipping_price['cost'], $config['base_currency_code'], $config['currency']);
}
}

return $config;
}

/**
* @param string|float $price
* @param string $baseCurrency
* @param string $currency
*
* @return float
*/
private function convertToCurrency($price, $baseCurrency, $currency)
{
return Mage::helper('directory')->currencyConvert($price, $baseCurrency, $currency);
}

/**
* @param int $storeId
* @param string $type
Expand Down
6 changes: 5 additions & 1 deletion app/code/community/Magmodules/Channable/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<config>
<modules>
<Magmodules_Channable>
<version>1.6.12</version>
<version>1.6.13</version>
</Magmodules_Channable>
</modules>
<global>
Expand Down Expand Up @@ -118,7 +118,11 @@
<delivery_out>1-7 Days</delivery_out>
<stock_status>1</stock_status>
<stock>1</stock>
<configurable_link>1</configurable_link>
</data>
<advanced>
<shipping_convert_prices>0</shipping_convert_prices>
</advanced>
<server>
<memory_limit>1024M</memory_limit>
<max_execution_time>300</max_execution_time>
Expand Down
26 changes: 25 additions & 1 deletion app/code/community/Magmodules/Channable/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,19 @@
</depends>
<comment>Only enable this option when you have enabled an extension that is using the simple prices in your store.</comment>
</simple_price>
<configurable_link translate="label">
<label>Use Parent URL for Simples</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>94</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<depends>
<conf_enabled>1</conf_enabled>
</depends>
<comment>Recommended: Yes</comment>
</configurable_link>
<conf_switch_urls translate="label">
<label>Configurable Switch Urls</label>
<frontend_type>select</frontend_type>
Expand All @@ -491,6 +504,7 @@
<show_in_store>1</show_in_store>
<depends>
<conf_enabled>1</conf_enabled>
<configurable_link>1</configurable_link>
</depends>
<comment>Create a specific url for the simple products inside the configurable products to make sure the prices and information is correct.</comment>
</conf_switch_urls>
Expand Down Expand Up @@ -556,11 +570,21 @@
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</shipping_method>
<shipping_convert_prices translate="label">
<label>Shipping Convert Prices</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>52</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment><![CDATA[Convert shipping prices from, to and cost from base currency to default currency.]]></comment>
</shipping_convert_prices>
<shipping_price>
<label>The Shipping Price</label>
<frontend_model>channable/adminhtml_config_form_field_shipping</frontend_model>
<backend_model>channable/adminhtml_system_config_backend_design_shipping</backend_model>
<sort_order>52</sort_order>
<sort_order>53</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "magmodules/magento1-channable",
"type": "magento-module",
"description": "Magento 1 Channable integration",
"version": "v1.6.12",
"version": "v1.6.13",
"keywords": [
"magento",
"channable"
Expand Down

0 comments on commit 23bb802

Please sign in to comment.