Skip to content

Commit

Permalink
Merge pull request #15 from magmodules/1.6.4
Browse files Browse the repository at this point in the history
1.6.4
  • Loading branch information
Marvin-Magmodules authored May 17, 2018
2 parents 54c6073 + 9370ed0 commit c1c13c6
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 12 deletions.
39 changes: 38 additions & 1 deletion app/code/community/Magmodules/Channable/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ public function getAttributeValue($field, $product, $config, $actions = '', $par
$field = 'attribute_set_name';
}

if (!empty($data['source']) && ($data['source'] == 'backorders')) {
$config['field']['backorders'] = $config['field'][$field];
$field = 'backorders';
}

switch ($field) {
case 'product_url':
$value = $this->getProductUrl($product, $config, $parent, $parentAttributes);
Expand Down Expand Up @@ -206,6 +211,9 @@ public function getAttributeValue($field, $product, $config, $actions = '', $par
case 'stock':
$value = $this->getStock($productData, $config['stock_bundle']);
break;
case 'backorders':
$value = $this->getBackordersEnabled($productData, $config);
break;
case 'categories':
$value = $this->getProductCategories($productData, $config);
break;
Expand Down Expand Up @@ -813,12 +821,41 @@ public function getStock($product, $bundleStock)
}
}

return min($avQty);
if (!empty($avQty)) {
return min($avQty);
} else {
return null;
}
}

return null;
}

/**
* @param Mage_Catalog_Model_Product $product
* @param $config
*
* @return mixed
*/
public function getBackordersEnabled($product, $config)
{
if ($product->getUseConfigManageStock()) {
$manageStock = $config['stock_manage'];
} else {
$manageStock = $product->getManageStock();
}

if (!$manageStock) {
return "0";
}

if ($product->getUseConfigBackorders()) {
return $config['backorders'];
}

return $product->getBackorders();
}

/**
* @param Mage_Catalog_Model_Product $product
* @param $config
Expand Down
16 changes: 12 additions & 4 deletions app/code/community/Magmodules/Channable/Helper/Selftest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class Magmodules_Channable_Helper_Selftest extends Magmodules_Channable_Helper_D

const SUPPORT_URL = 'https://www.magmodules.eu/help/channable-connect/channable-selftest-results';
const GITHUB_URL = 'https://api.github.com/repos/magmodules/magento1-channable/tags';
const GITHUB_CHANNABLE_API_URL = 'https://github.com/magmodules/magento1-channable-api/releases';
const GITHUB_CHANNABLE_URL = 'https://github.com/magmodules/magento1-channable/releases';
const API_MIN_REQUIREMENT = '1.2.0';

/**
Expand Down Expand Up @@ -100,8 +102,12 @@ public function runTests()
$latestVersion['version']);
$result[] = $this->getPass($msg);
} else {
$msg = $this->__('v%s is latest version, currenlty running v%s, please update!',
$latestVersion['version'], $currentVersion);
$msg = $this->__(
'v%s is latest version, currenlty running v%s. %s',
$latestVersion['version'],
$currentVersion,
'<a href="' . self::GITHUB_CHANNABLE_URL . '">[' . $this->__('Download') . ']</a>'
);
$result[] = $this->getNotice($msg, '#update');
}
} else {
Expand Down Expand Up @@ -245,9 +251,11 @@ public function checkChannableApiModule()
} else {
return array(
'error' => $this->__(
'Channable API Module needs update (Installed: v%s - Min. required: v%s)',
'Channable API Module needs update (Installed: v%s - Min. required: v%s). %s',
$currentVersion,
self::API_MIN_REQUIREMENT)
self::API_MIN_REQUIREMENT,
'<a href="' . self::GITHUB_CHANNABLE_API_URL . '">[' . $this->__('Download') . ']</a>'
),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ public function getExtraFields()
'label' => Mage::helper('channable')->__('Minumun Sales Quantity'),
'value' => 'min_sale_qty'
);

$optionArray[] = array(
'label' => Mage::helper('channable')->__('Backorders'),
'value' => 'backorders'
);
return $optionArray;
}

Expand Down
5 changes: 5 additions & 0 deletions app/code/community/Magmodules/Channable/Model/Channable.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public function getFeedConfig($storeId, $type = 'xml')
$config['stock_manage'] = Mage::getStoreConfig('cataloginventory/item_options/manage_stock');
$config['use_qty_increments'] = Mage::getStoreConfig('cataloginventory/item_options/enable_qty_increments');
$config['qty_increments'] = Mage::getStoreConfig('cataloginventory/item_options/qty_increments');
$config['backorders'] = Mage::getStoreConfig('cataloginventory/item_options/backorders');
$config['delivery'] = Mage::getStoreConfig('channable/data/delivery', $storeId);
$config['delivery_be'] = Mage::getStoreConfig('channable/data/delivery_be', $storeId);
$config['delivery_att'] = Mage::getStoreConfig('channable/data/delivery_att', $storeId);
Expand Down Expand Up @@ -360,6 +361,10 @@ public function getFeedData($products, $parents, $config, $parentAttributes, $pr
$productRow = array_merge($productRow, $extraData);
}

$productRow = new Varien_Object($productRow);
Mage::dispatchEvent('channable_feed_item_before', array('feed_data' => $productRow , 'product' => $product));
$productRow = $productRow->getData();

$feed[] = $productRow;
if ($config['item_updates']) {
$this->processItemUpdates($productRow, $config['store_id']);
Expand Down
12 changes: 8 additions & 4 deletions app/code/community/Magmodules/Channable/Model/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ public function getProducts($config, $productIds = array())
"min_sale_qty" => "min_sale_qty",
"qty_increments" => "qty_increments",
"enable_qty_increments" => "enable_qty_increments",
"use_config_qty_increments" => "use_config_qty_increments"
"use_config_qty_increments" => "use_config_qty_increments",
"backorders" => "backorders",
"use_config_backorders" => "use_config_backorders",
)
)->addAttributeToSelect(
array(
Expand All @@ -100,10 +102,12 @@ public function getProducts($config, $productIds = array())
'min_sale_qty',
'qty_increments',
'enable_qty_increments',
'use_config_qty_increments'
'use_config_qty_increments',
'backorders',
'use_config_backorders'
)
);

$this->joinPriceIndexLeft($collection, $websiteId);
$collection->getSelect()->group('e.entity_id');

Expand All @@ -130,7 +134,7 @@ public function joinPriceIndexLeft($collection, $websiteId)
$colls = array('final_price', 'min_price', 'max_price');
$collection->getSelect()->joinLeft($tableName, $joinCond, $colls);
}

/**
* @param $selectedAttrs
*
Expand Down
2 changes: 1 addition & 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.3</version>
<version>1.6.4</version>
</Magmodules_Channable>
</modules>
<global>
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.3",
"version": "v1.6.4",
"keywords": [
"magento"
],
Expand Down

0 comments on commit c1c13c6

Please sign in to comment.