diff --git a/.gitignore b/.gitignore index 9bfd72f..003c634 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -.idea/* +.idea *.zip .DS_Store \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Extra.php b/app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Extra.php old mode 100755 new mode 100644 index e6ce93f..b188922 --- a/app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Extra.php +++ b/app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Extra.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules toOptionArray() ); + $rendererTypes = $layout->createBlock( + 'channable/adminhtml_config_form_renderer_select', + '', + array('is_render_to_js_template' => true) + ); + + $rendererTypes->setOptions( + Mage::getModel('channable/adminhtml_system_config_source_producttypes')->toOptionArray() + ); + $this->addColumn( 'attribute', array( 'label' => Mage::helper('channable')->__('Attribute'), @@ -73,8 +86,18 @@ public function __construct() ) ); + $this->addColumn( + 'product_type', array( + 'label' => Mage::helper('channable')->__('Apply To'), + 'style' => 'width:150px', + 'renderer' => $rendererTypes + ) + ); + + $this->_renders['attribute'] = $rendererAttributes; $this->_renders['condition'] = $rendererConditions; + $this->_renders['product_type'] = $rendererTypes; $this->_addAfter = false; $this->_addButtonLabel = Mage::helper('channable')->__('Add Filter'); diff --git a/app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Shipping.php b/app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Shipping.php old mode 100755 new mode 100644 index 30718ae..4f96c75 --- a/app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Shipping.php +++ b/app/code/community/Magmodules/Channable/Block/Adminhtml/Config/Form/Field/Shipping.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '; + $html .= ''; foreach ($value as $keyGroup => $optionGroup) { if (!is_array($optionGroup)) { $optionGroup = array( diff --git a/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Button.php b/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Button.php new file mode 100644 index 0000000..8933608 --- /dev/null +++ b/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Button.php @@ -0,0 +1,80 @@ + + * @copyright Copyright (c) 2018 (http://www.magmodules.eu) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Button + extends Mage_Adminhtml_Block_System_Config_Form_Field +{ + + /** + * @var Mage_Adminhtml_Helper_Data + */ + public $helper; + + /** + * @inheritdoc. + */ + public function _construct() + { + parent::_construct(); + $this->setTemplate('magmodules/channable/system/config/test_button.phtml'); + $this->helper = Mage::helper('adminhtml'); + } + + /** + * Return element html + * + * @param Varien_Data_Form_Element_Abstract $element + * + * @return string + */ + public function _getElementHtml(Varien_Data_Form_Element_Abstract $element) + { + return $this->_toHtml(); + } + + /** + * Return ajax url for button + * + * @return string + */ + public function getAjaxCheckUrl() + { + return $this->helper->getUrl('adminhtml/selftest/run'); + } + + /** + * Generate button html + * + * @return string + */ + public function getButtonHtml() + { + $button = $this->getLayout()->createBlock('adminhtml/widget_button') + ->setData( + array( + 'id' => 'test_check_button', + 'label' => $this->helper('adminhtml')->__('Run'), + 'onclick' => 'javascript:testModule(); return false;' + ) + ); + + return $button->toHtml(); + } +} \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Feeds.php b/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Feeds.php old mode 100755 new mode 100644 index a5993ce..270be69 --- a/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Feeds.php +++ b/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Feeds.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules getStoreIds('channable/connect/enabled'); - $token = Mage::helper('channable')->getToken(); + $token = $helper->getToken(); $sHtml = ''; if ($token) { foreach ($storeIds as $storeId) { - $baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); - $channableFeed = $baseUrl . 'channable/feed/get/code/' . $token . '/store/' . $storeId . '/array/1'; - $storeTitle = Mage::app()->getStore($storeId)->getName(); - $url = 'https://app.channable.com/connect/magento.html?'; - $url .= 'store_id=' . $storeId . '&url=' . $baseUrl . '&token=' . $token; - $msg = $this->__('Click to auto connect with Channable'); + $store = Mage::getModel('core/store')->load($storeId); + $baseUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); - $sHtml .= ' - ' . $storeTitle . ' - ' . $this->__('Preview') . ' - ' . $msg . ' - '; + $url = sprintf( + 'https://app.channable.com/connect/magento.html?store_id=%s&url=%s&token=%s', + $storeId, + $baseUrl, + $token + ); + + $sHtml .= sprintf( + '%s%s%s%s', + $store->getWebsite()->getName(), + $store->getName(), + $baseUrl . 'channable/feed/get/code/' . $token . '/store/' . $storeId . '/array/1', + $this->__('Preview'), + $url, + $this->__('Click to auto connect with Channable') + ); } } @@ -56,13 +63,20 @@ public function render(Varien_Data_Form_Element_Abstract $element) $html = $helper->__('No enabled feed(s) found or token missing'); } else { $html = '
- - - - - ' . $sHtml . ' -
StorePreviewConnect
-
'; + + + + + + + + + + + ' . $sHtml . ' + +
' . $helper->__('Website') .'' . $helper->__('Store') .'' . $helper->__('Preview') .'' . $helper->__('Connect') .'
+ '; } return sprintf( diff --git a/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Heading.php b/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Heading.php old mode 100755 new mode 100644 index 1c6df70..3fbf1d1 --- a/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Heading.php +++ b/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Heading.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules

%s

', - $element->getHtmlId(), - $element->getLabel() + $html = sprintf( + ' + + +

%s

+
+ %s +
+ + ', + $element->getHtmlId(), $element->getHtmlId(), $element->getLabel(), $element->getComment() ); + + return $html; } } diff --git a/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Note.php b/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Note.php old mode 100755 new mode 100644 index cd70f38..2802493 --- a/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Note.php +++ b/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Note.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules + * @copyright Copyright (c) 2018 (http://www.magmodules.eu) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Magmodules_Channable_Block_Adminhtml_System_Config_Form_Field_Result + extends Mage_Adminhtml_Block_System_Config_Form_Field +{ + + /** + * Return element html. + * + * @param Varien_Data_Form_Element_Abstract $element + * + * @return string + */ + public function _getElementHtml(Varien_Data_Form_Element_Abstract $element) + { + return $this->_toHtml(); + } + + /** + * @param Varien_Data_Form_Element_Abstract $element + * + * @return string + */ + public function render(Varien_Data_Form_Element_Abstract $element) + { + return sprintf( + '', + $element->getHtmlId() + ); + } + +} \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Token.php b/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Token.php old mode 100755 new mode 100644 index c17f25e..72045fd --- a/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Token.php +++ b/app/code/community/Magmodules/Channable/Block/Adminhtml/System/Config/Form/Field/Token.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules getNode('modules')->children(); - $modulesArray = (array) $modules; + $modulesArray = (array)$modules; return $modulesArray['Magmodules_Channable']->version; } diff --git a/app/code/community/Magmodules/Channable/Block/Adminhtml/Widget/Info/Info.php b/app/code/community/Magmodules/Channable/Block/Adminhtml/Widget/Info/Info.php old mode 100755 new mode 100644 index 5f32e29..f515082 --- a/app/code/community/Magmodules/Channable/Block/Adminhtml/Widget/Info/Info.php +++ b/app/code/community/Magmodules/Channable/Block/Adminhtml/Widget/Info/Info.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules getNode()->modules->Magmodules_Channable->version; - $logoLink = '//www.magmodules.eu/logo/channable/' . $moduleVersion . '/' . $magentoVersion . '/logo.png'; - $html = '
-

About Magmodules.eu

-

We are a Magento only E-commerce Agency located in the Netherlands.
-
- - - - - - - - - - - - - - - - - -
More Extensions from Magmodules: - - Magento Connect - -
For Help:Visit our Support Page
Visit Our Website:www.magmodules.eu
- Read everything about the extension configuration in our - Knowledgebase - . -  
-

'; - - if (Mage::helper('channable')->checkOldVersion('Channable')) { - $msg = '
    • ' . Mage::helper('channable')->__('Old version detected on the server, please remove the directory app/code/local/Magmodules/Channable and flush cache!') . '
'; - $html = $msg . $html; - } - - $flatProduct = Mage::getStoreConfig('catalog/frontend/flat_catalog_product'); - $flatCategoy = Mage::getStoreConfig('catalog/frontend/flat_catalog_category'); - if ((!$flatProduct) || (!$flatCategoy)) { - $msg = '
    • ' . Mage::helper('channable')->__('Please enable "Flat Catalog Category" and "Flat Catalog Product" for the extension to work properly. More information.') . '
'; - $html = $html . $msg; - } - - if (empty($oldversion)) { - if (Mage::getStoreConfig('catalog/frontend/flat_catalog_product')) { - $storeId = Mage::helper('channable')->getStoreIdConfig(); - $nonFlatAttributes = Mage::helper('channable')->checkFlatCatalog( - Mage::getModel("channable/channable")->getFeedAttributes( - '', - $storeId - ) - ); - if (!empty($nonFlatAttributes)) { - $html .= '
    • '; - $html .= $this->__( - 'Warning: The following used attribute(s) were not found in the flat catalog: %s. This can result in empty data or higher resource usage. Click here to add these to the flat catalog. ', - implode($nonFlatAttributes, ', '), $this->getUrl('adminhtml/channable/addToFlat') - ); - $html .= '
'; - } - } - } +

About Magmodules.eu

+

We are a Magento only E-commerce Agency located in the Netherlands.
+
+ + + + + + + + + + + + + +
More Extensions from Magmodules: + + Magento Connect + +
For Help:Visit our Support Page
Visit Our Website:www.magmodules.eu

+

Read everything about the extension configuration in our Knowledgebase.

+

Perform a Selftest to check your setup through the selftest button on the Advanced tab of this configuration page.

+ '; return $html; } diff --git a/app/code/community/Magmodules/Channable/Helper/Data.php b/app/code/community/Magmodules/Channable/Helper/Data.php old mode 100755 new mode 100644 index 0732c26..07c7c37 --- a/app/code/community/Magmodules/Channable/Helper/Data.php +++ b/app/code/community/Magmodules/Channable/Helper/Data.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules getStores() as $store) { - $storeId = Mage::app()->getStore($store)->getId(); - if (Mage::getStoreConfig($path, $storeId)) { - $storeIds[] = $storeId; + $stores = Mage::getModel('core/store')->getCollection(); + foreach ($stores as $store) { + if (Mage::getStoreConfig($path, $store->getId())) { + $storeIds[] = $store->getId(); } } @@ -50,6 +53,7 @@ public function getStoreIds($path) */ public function getProductDataRow($product, $config, $parent, $parentAttributes) { + $fields = $config['field']; $data = array(); @@ -149,7 +153,7 @@ public function validateProduct($product, $config, $parent) * @param Mage_Catalog_Model_Product $parent * @param $parentAttributes * - * @return string + * @return mixed */ public function getAttributeValue($field, $product, $config, $actions = '', $parent, $parentAttributes) { @@ -201,7 +205,7 @@ public function getAttributeValue($field, $product, $config, $actions = '', $par $value = $this->getProductCategories($productData, $config); break; case 'category_ids': - $value = $this->getProductCategoryIds($productData, $config); + $value = $this->getProductCategoryIds($productData); break; default: if (!empty($data['source'])) { @@ -224,7 +228,7 @@ public function getAttributeValue($field, $product, $config, $actions = '', $par } } - if ((isset($actions)) && (!empty($value))) { + if ((isset($actions)) && (!empty($value)) && !is_array($value)) { $value = $this->cleanData($value, $actions); } @@ -281,16 +285,20 @@ public function getProductUrl($product, $config, $parent, $parentAttributes) } } - if (!empty($parent) && !empty($url)) { - if (!empty($parentAttributes[$parent->getEntityId()])) { - $storeId = $config['store_id']; - $pId = $product->getId(); + if (!empty($config['url_suffix'])) { + $url = $url . '?' . $config['url_suffix']; + } + + if (!empty($parent) && !empty($config['conf_switch_urls'])) { + if ($parent->getTypeId() == 'configurable') { $productAttributeOptions = $parentAttributes[$parent->getEntityId()]; $urlExtra = ''; foreach ($productAttributeOptions as $productAttribute) { - $attCode = $productAttribute['attribute_code']; - $id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($pId, $attCode, $storeId); - if ($id > 0) { + if ($id = Mage::getResourceModel('catalog/product')->getAttributeRawValue( + $product->getId(), + $productAttribute['attribute_code'], $config['store_id'] + ) + ) { $urlExtra .= $productAttribute['attribute_id'] . '=' . $id . '&'; } } @@ -324,7 +332,6 @@ public function getProductImage($product, $config) } $productImage = $imageModel->getUrl(); - return (string)$productImage; } else { $image = ''; @@ -337,7 +344,7 @@ public function getProductImage($product, $config) $mediaData = $product->getData($mediaAtt); if (!empty($mediaData)) { if ($mediaData != 'no_selection') { - $image = $config['media_image_url'] . $mediaData; + $image = $this->checkImagePath($mediaData, $config['media_image_url']); $imageData['image'][$mediaAtt] = $image; } } @@ -345,21 +352,21 @@ public function getProductImage($product, $config) } else { if ($product->getThumbnail()) { if ($product->getThumbnail() != 'no_selection') { - $image = $config['media_image_url'] . $product->getThumbnail(); + $image = $this->checkImagePath($product->getThumbnail(), $config['media_image_url']); $imageData['image']['thumbnail'] = $image; } } if ($product->getSmallImage()) { if ($product->getSmallImage() != 'no_selection') { - $image = $config['media_image_url'] . $product->getSmallImage(); + $image = $this->checkImagePath($product->getSmallImage(), $config['media_image_url']); $imageData['image']['small_image'] = $image; } } if ($product->getImage()) { if ($product->getImage() != 'no_selection') { - $image = $config['media_image_url'] . $product->getImage(); + $image = $this->checkImagePath($product->getImage(), $config['media_image_url']); $imageData['image']['image'] = $image; } } @@ -367,29 +374,25 @@ public function getProductImage($product, $config) if (!empty($config['images'])) { $imageData['image_link'] = $image; - $container = new Varien_Object( - array( - 'attribute' => new Varien_Object(array('id' => $config['media_gallery_id'])) - ) - ); + $container = new Varien_Object(array('attribute' => new Varien_Object(array('id' => $config['media_gallery_id'])))); $imgProduct = new Varien_Object(array('id' => $product->getId(), 'store_id' => $config['store_id'])); - $gallery = Mage::getResourceModel('catalog/product_attribute_backend_media')->loadGallery( - $imgProduct, - $container - ); - + $gallery = Mage::getResourceModel('catalog/product_attribute_backend_media') + ->loadGallery($imgProduct, $container); $i = 1; usort( $gallery, function ($a, $b) { return $a['position_default'] > $b['position_default']; } ); - foreach ($gallery as $galleryImage) { - if ($galleryImage['disabled'] == 0) { - $imageData['image']['all']['image_' . $i] = $config['media_image_url'] . $galleryImage['file']; - $imageData['image']['last'] = $config['media_image_url'] . $galleryImage['file']; + foreach ($gallery as $galImage) { + if ($galImage['disabled'] == 0) { + $imageData['image']['all']['image_' . $i] = $this->checkImagePath($galImage['file'], + $config['media_image_url']); + $imageData['image']['last'] = $this->checkImagePath($galImage['file'], + $config['media_image_url']); if ($i == 1) { - $imageData['image']['first'] = $config['media_image_url'] . $galleryImage['file']; + $imageData['image']['first'] = $this->checkImagePath($galImage['file'], + $config['media_image_url']); } $i++; @@ -407,6 +410,25 @@ public function getProductImage($product, $config) } } + /** + * @param $path + * @param $mediaUrl + * + * @return string + */ + public function checkImagePath($path, $mediaUrl) + { + if (substr($path, 0, 4) === 'http') { + return $path; + } + + if ($path[0] != '/') { + return $mediaUrl . '/' . $path; + } else { + return $mediaUrl . $path; + } + } + /** * @param Mage_Catalog_Model_Product $product * @param $config @@ -501,10 +523,8 @@ public function getProductPrice($product, $config) } if (!empty($config['price_scope'])) { - $price = Mage::getResourceModel('catalog/product')->getAttributeRawValue( - $product->getId(), 'price', - $config['store_id'] - ); + $price = Mage::getResourceModel('catalog/product') + ->getAttributeRawValue($product->getId(), 'price', $config['store_id']); } else { $price = $product->getPrice(); } @@ -547,10 +567,15 @@ public function getProductPrice($product, $config) $priceData['final_price_clean'] = $price; $priceData['price'] = number_format(($price * $priceMarkup), 2, '.', '') . $currency; - $minPrice = Mage::helper('tax')->getPrice($product, $product->getMinPrice(), $taxParam); - $maxPrice = Mage::helper('tax')->getPrice($product, $product->getMaxPrice(), $taxParam); - $priceData['min_price'] = number_format(($minPrice * $priceMarkup), 2, '.', '') . $currency; - $priceData['max_price'] = number_format(($maxPrice * $priceMarkup), 2, '.', '') . $currency; + if ($product->getMinPrice() !== null) { + $minPrice = Mage::helper('tax')->getPrice($product, $product->getMinPrice(), $taxParam); + $priceData['min_price'] = number_format(($minPrice * $priceMarkup), 2, '.', '') . $currency; + } + + if ($product->getMaxPrice() !== null) { + $maxPrice = Mage::helper('tax')->getPrice($product, $product->getMaxPrice(), $taxParam); + $priceData['max_price'] = number_format(($maxPrice * $priceMarkup), 2, '.', '') . $currency; + } if (isset($salesPrice)) { $priceData['sales_price'] = number_format(($salesPrice * $priceMarkup), 2, '.', '') . $currency; @@ -572,11 +597,8 @@ public function getPriceMarkup($config) } if ($config['base_currency_code'] != $config['currency']) { - $exchangeRate = Mage::helper('directory')->currencyConvert( - 1, - $config['base_currency_code'], - $config['currency'] - ); + $exchangeRate = Mage::helper('directory') + ->currencyConvert(1, $config['base_currency_code'], $config['currency']); $markup = ($markup * $exchangeRate); } @@ -664,11 +686,9 @@ public function getPriceGrouped($product, $pricemodel = '') */ public function getProductBundle($product) { - if ($product->getTypeId() == 'bundle') { return 'true'; } - return false; } @@ -694,13 +714,13 @@ public function getIsInStock($product, $config) } /** - * @param Mage_Catalog_Model_Product $product - * @param $data - * @param string $config + * @param Mage_Catalog_Model_Product $product + * @param $data + * @param array $config * * @return string */ - public function getProductData($product, $data, $config = '') + public function getProductData($product, $data, $config = array()) { $type = $data['type']; $source = $data['source']; @@ -715,9 +735,8 @@ public function getProductData($product, $data, $config = '') } break; case 'select': - $attributetext = $product->getAttributeText($source); - if (!empty($attributetext)) { - $value = $attributetext; + if (!empty($source)) { + $value = $product->getAttributeText($source); } break; case 'multiselect': @@ -730,6 +749,17 @@ public function getProductData($product, $data, $config = '') $value = $attributetext; } break; + case 'float': + if (!empty($source) && isset($product[$source])) { + $value = round(floatval($product[$source])); + } + break; + case 'boolean': + $value = 0; + if (!empty($source) && isset($product[$source])) { + $value = (int)$product[$source]; + } + break; default: if (isset($product[$source])) { $value = $product[$source]; @@ -752,8 +782,9 @@ public function getAttributeSetName($product) /** * @param Mage_Catalog_Model_Product $product + * @param $bundleStock * - * @return string + * @return mixed|null */ public function getStock($product, $bundleStock) { @@ -816,16 +847,6 @@ public function getProductCategories($product, $config) } } - /** - * @param Mage_Catalog_Model_Product $product - * - * @return string - */ - public function getProductCategoryIds($product) - { - return implode(',', $product->getCategoryIds()); - } - /** * @param $data * @param $sort @@ -840,6 +861,16 @@ function getSortedArray($data, $sort) return array_reverse($data); } + /** + * @param Mage_Catalog_Model_Product $product + * + * @return string + */ + public function getProductCategoryIds($product) + { + return implode(',', $product->getCategoryIds()); + } + /** * @param $st * @param string $action @@ -949,25 +980,31 @@ public function getTaxUsage($config) } /** - * @param $attributes - * @param string $config + * @param $attributes + * @param array $config * * @return mixed */ - public function addAttributeData($attributes, $config = '') + public function addAttributeData($attributes, $config = array()) { foreach ($attributes as $key => $attribute) { $type = (!empty($attribute['type']) ? $attribute['type'] : ''); $action = (!empty($attribute['action']) ? $attribute['action'] : ''); $parent = (!empty($attribute['parent']) ? $attribute['parent'] : ''); if (isset($attribute['source'])) { - $attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode( - 'catalog_product', - $attribute['source'] - ); + $attributeModel = Mage::getModel('eav/entity_attribute') + ->loadByCode('catalog_product', $attribute['source']); + $type = $attributeModel->getFrontendInput(); } + if (!empty($attribute['label']) && ($attribute['label'] == 'manage_stock')) { + $type = 'boolean'; + } + if (!empty($attribute['label']) && ($attribute['label'] == 'qty')) { + $type = 'float'; + } + if (!empty($config['conf_fields'])) { $confAttributes = explode(',', $config['conf_fields']); if (in_array($key, $confAttributes)) { @@ -996,7 +1033,6 @@ public function addAttributeData($attributes, $config = '') public function getCategoryData($config, $storeId) { $defaultAttributes = array('entity_id', 'path', 'name', 'level'); - $attributes = $defaultAttributes; if (!empty($config['category_custom'])) { @@ -1025,12 +1061,14 @@ public function getCategoryData($config, $storeId) } if (empty($e)) { + /** @var Mage_Catalog_Model_Resource_Category_Collection $categories */ $categories = Mage::getModel('catalog/category') ->setStoreId($storeId) ->getCollection() ->addAttributeToSelect($attributes) ->addFieldToFilter('is_active', array('eq' => 1)); } else { + /** @var Mage_Catalog_Model_Resource_Category_Collection $categories */ $categories = Mage::getModel('catalog/category') ->setStoreId($storeId) ->getCollection() @@ -1117,37 +1155,54 @@ public function getCategoryData($config, $storeId) } /** - * @param Mage_Catalog_Model_Product $product - * @param $config + * @param $products + * @param $config * - * @return bool + * @return array */ - public function getParentData($product, $config) + public function getParentsFromCollection($products, $config) { - if (!empty($config['conf_enabled'])) { - if (($product['type_id'] == 'simple')) { - $configIds = Mage::getModel('catalog/product_type_configurable') - ->getParentIdsByChild($product->getId()); - $groupIds = Mage::getResourceSingleton('catalog/product_link')->getParentIdsByChild( - $product->getId(), - Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED - ); - if ($configIds) { - return $configIds[0]; - } + $ids = array(); + if (empty($config['conf_enabled'])) { + return $ids; + } - if ($groupIds) { - return $groupIds[0]; - } + foreach ($products as $product) { + if ($parentId = $this->getParentData($product)) { + $ids[$product->getEntityId()] = $parentId; } } - return false; + return $ids; } /** - * @param $config - * @param Mage_Catalog_Model_Product $products + * @param Mage_Catalog_Model_Product $product + * + * @return array + */ + public function getParentData($product) + { + if (($product['type_id'] == 'simple')) { + $configIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId()); + if ($configIds) { + return $configIds; + } + + $groupIds = Mage::getResourceSingleton('catalog/product_link')->getParentIdsByChild( + $product->getId(), + Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED + ); + + if ($groupIds) { + return $groupIds; + } + } + } + + /** + * @param $config + * @param $products * * @return array */ @@ -1252,11 +1307,8 @@ public function checkOldVersion($dir) { if ($dir) { $dir = Mage::getBaseDir('app') . DS . 'code' . DS . 'local' . DS . 'Magmodules' . DS . $dir; - return file_exists($dir); } - - return false; } /** @@ -1267,14 +1319,12 @@ public function checkOldVersion($dir) public function checkFlatCatalog($attributes) { $nonFlatAttributes = array(); - $skipCheck = array('sku','category_ids'); + $skipCheck = array('sku', 'category_ids'); foreach ($attributes as $key => $attribute) { if (!empty($attribute['source'])) { if (($attribute['source'] != 'entity_id') && !in_array($attribute['source'], $skipCheck)) { - $_attribute = Mage::getModel('eav/entity_attribute')->loadByCode( - 'catalog_product', - $attribute['source'] - ); + $_attribute = Mage::getModel('eav/entity_attribute') + ->loadByCode('catalog_product', $attribute['source']); if ($_attribute->getUsedInProductListing() == 0) { if ($_attribute->getId()) { $nonFlatAttributes[$_attribute->getId()] = $_attribute->getFrontendLabel(); @@ -1287,16 +1337,31 @@ public function checkFlatCatalog($attributes) return $nonFlatAttributes; } + /** + * @param $storeId + * + * @return mixed|string + */ + public function getProductUrlSuffix($storeId) + { + $suffix = Mage::getStoreConfig('catalog/seo/product_url_suffix', $storeId); + if (!empty($suffix)) { + if ((strpos($suffix, '.') === false) && ($suffix != '/')) { + $suffix = '.' . $suffix; + } + } + + return $suffix; + } + /** * @return array */ public function getMediaAttributes() { $mediaTypes = array(); - $attributes = Mage::getResourceModel('catalog/product_attribute_collection')->addFieldToFilter( - 'frontend_input', - 'media_image' - ); + $attributes = Mage::getResourceModel('catalog/product_attribute_collection') + ->addFieldToFilter('frontend_input', 'media_image'); foreach ($attributes as $attribute) { $mediaTypes[] = $attribute->getData('attribute_code'); } @@ -1318,23 +1383,6 @@ public function getStoreIdConfig() return $storeId; } - /** - * @param $storeId - * - * @return string - */ - public function getProductUrlSuffix($storeId) - { - $suffix = Mage::getStoreConfig('catalog/seo/product_url_suffix', $storeId); - if (!empty($suffix)) { - if (($suffix[0] != '.') && ($suffix != '/')) { - $suffix = '.' . $suffix; - } - } - - return $suffix; - } - /** * @return bool|mixed */ @@ -1370,4 +1418,49 @@ public function getUncachedConfigValue($path, $storeId = 0) return $collection->getFirstItem()->getValue(); } + + /** + * @param $page + * @param $pages + * @param $processed + */ + public function addLog($page, $pages, $processed) + { + $memoryUsage = memory_get_usage(true); + if ($memoryUsage < 1024) { + $usage = $memoryUsage . ' b'; + } elseif ($memoryUsage < 1048576) { + $usage = round($memoryUsage / 1024, 2) . ' KB'; + } else { + $usage = round($memoryUsage / 1048576, 2) . ' MB'; + } + + $msg = sprintf( + 'Page: %s/%s | Memory Usage: %s | Products: %s', + $page, + $pages, + $usage, + $processed + ); + + Mage::log($msg, null, self::LOG_FILENAME, self::FORCE_LOG); + } + + /** + * @param $timeStart + * + * @return float|string + */ + public function getTimeUsage($timeStart) + { + + $time = round((microtime(true) - $timeStart)); + if ($time > 120) { + $time = round($time / 60, 1) . ' ' . $this->__('minutes'); + } else { + $time = round($time) . ' ' . $this->__('seconds'); + } + + return $time; + } } diff --git a/app/code/community/Magmodules/Channable/Helper/Selftest.php b/app/code/community/Magmodules/Channable/Helper/Selftest.php new file mode 100644 index 0000000..ad20649 --- /dev/null +++ b/app/code/community/Magmodules/Channable/Helper/Selftest.php @@ -0,0 +1,249 @@ + + * @copyright Copyright (c) 2018 (http://www.magmodules.eu) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Magmodules_Channable_Helper_Selftest extends Magmodules_Channable_Helper_Data +{ + + 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 API_MIN_REQUIREMENT = '1.2.0'; + + /** + * + */ + public function runTests() + { + $result = array(); + + /** @var Magmodules_Channable_Model_Channable $model */ + $model = Mage::getModel("channable/channable"); + + $enabled = Mage::getStoreConfig('channable/connect/enabled'); + if ($enabled) { + $result[] = $this->getPass('Module Enabled'); + } else { + $result[] = $this->getFail('Module Disabled'); + } + + $local = $this->checkOldVersion('Channable'); + if ($local) { + $result[] = $this->getNotice('Old version or local overwrite detected', '#local'); + } + + $flatProduct = Mage::getStoreConfig('catalog/frontend/flat_catalog_product'); + $bypassFlat = Mage::getStoreConfig('channable/server/bypass_flat'); + + if ($flatProduct) { + if ($bypassFlat) { + $result[] = $this->getNotice('Catalog Product Flat bypass is enabled', '#bypass'); + } else { + $result[] = $this->getPass('Catalog Product Flat is enabled'); + + $storeId = $this->getStoreIdConfig(); + $nonFlatAttributes = $this->checkFlatCatalog($model->getFeedAttributes('', $storeId)); + + if (!empty($nonFlatAttributes)) { + $atts = '' . implode($nonFlatAttributes, ', ') . ''; + $url = Mage::helper("adminhtml")->getUrl('adminhtml/channable/addToFlat'); + $msg = $this->__('Missing Attribute(s) in Catalog Product Flat: %s', $atts); + $msg .= '
' . $this->__('Add attributes to Flat Catalog or enable "Bypass Flat Product Tables"', + $url); + $result[] = $this->getFail($msg, '#missingattributes'); + } + } + } else { + $result[] = $this->getNotice('Catalog Product Flat is disabled', '#flatcatalog'); + } + + $flatCategoy = Mage::getStoreConfig('catalog/frontend/flat_catalog_category'); + if ($flatCategoy) { + $result[] = $this->getPass('Catalog Catagory Flat is enabled'); + } else { + $result[] = $this->getNotice('Catalog Catagory Flat is disabled', '#flatcatalog'); + } + + if (!$this->getToken()) { + $url = Mage::helper("adminhtml")->getUrl('adminhtml/channable/createToken'); + $msg = $this->__('Token missing, Create New', $url); + $result[] = $this->getFail($msg, '#token'); + } + + $latestVersion = $this->latestVersion(); + if (isset($latestVersion['version'])) { + $modulesArray = (array)Mage::getConfig()->getNode('modules')->children(); + $currentVersion = $modulesArray['Magmodules_Channable']->version; + if (version_compare($currentVersion, $latestVersion['version']) >= 0) { + $msg = $this->__('Running the latest version (Installed: v%s - Github: v%s)', $currentVersion, + $latestVersion['version']); + $result[] = $this->getPass($msg); + } else { + $msg = $this->__('v%s is latest version, currenlty running v%s, please update!', + $latestVersion['version'], $currentVersion); + $result[] = $this->getNotice($msg, '#update'); + } + } else { + $result[] = $this->getFail($latestVersion['error'], '#update-error'); + } + + if ($apiModule = $this->checkChannableApiModule()) { + if (!empty($apiModule['success'])) { + $result[] = $this->getPass($apiModule['success']); + } + if (!empty($apiModule['error'])) { + $result[] = $this->getFail($apiModule['error']); + } + } + + return $result; + } + + /** + * @param $msg + * @param string $link + * + * @return string + */ + public function getPass($msg, $link = null) + { + return $this->getHtmlResult($msg, 'pass', $link); + } + + /** + * @param $msg + * @param $type + * @param string $link + * + * @return string + */ + public function getHtmlResult($msg, $type, $link) + { + $format = null; + + if ($type == 'pass') { + $format = '%s'; + } + if ($type == 'fail') { + $format = '%s'; + } + if ($type == 'notice') { + $format = '%s'; + } + + if ($format) { + if ($link) { + $format = str_replace('', 'More Info', + $format); + return sprintf($format, Mage::helper('channable')->__($msg), self::SUPPORT_URL . $link); + } else { + return sprintf($format, Mage::helper('channable')->__($msg)); + } + } + } + + /** + * @param $msg + * @param string $link + * + * @return string + */ + public function getFail($msg, $link = null) + { + return $this->getHtmlResult($msg, 'fail', $link); + } + + /** + * @param $msg + * @param string $link + * + * @return string + */ + public function getNotice($msg, $link = null) + { + return $this->getHtmlResult($msg, 'notice', $link); + } + + /** + * @return array + */ + public function latestVersion() + { + $version = null; + $error = null; + + try { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, self::GITHUB_URL); + curl_setopt($ch, CURLOPT_USERAGENT, 'Version Check Magento 1'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); + curl_setopt($ch, CURLOPT_TIMEOUT, 5); + $data = curl_exec($ch); + $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + + if ($httpcode >= 200 && $httpcode < 300) { + $data = json_decode($data, true); + if (isset($data[0]['name'])) { + $version = str_replace(array('v.', 'v'), '', $data[0]['name']); + } + } + } catch (\Exception $exception) { + $error = $exception->getMessage(); + return array('error' => $this->__('Could not fetch latest version from Github, error: %s', $error)); + } + + if ($version) { + return array('version' => $version); + } else { + return array('error' => $this->__('Could not fetch latest version from Github')); + } + } + + /** + * @return array|bool + */ + public function checkChannableApiModule() + { + $modulesArray = (array)Mage::getConfig()->getNode('modules')->children(); + + if (!isset($modulesArray['Magmodules_Channableapi'])) { + return false; + } + + $currentVersion = $modulesArray['Magmodules_Channableapi']->version; + + if (version_compare($currentVersion, self::API_MIN_REQUIREMENT) >= 0) { + return array( + 'success' => $this->__( + 'Running minumum required Channable API Module (Installed: v%s - Min. required: v%s)', + $currentVersion, + self::API_MIN_REQUIREMENT) + ); + } else { + return array( + 'error' => $this->__( + 'Channable API Module needs update (Installed: v%s - Min. required: v%s)', + $currentVersion, + self::API_MIN_REQUIREMENT) + ); + } + } + +} diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Extra.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Extra.php old mode 100755 new mode 100644 index 5d2bb75..930c7de --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Extra.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Extra.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules getValue(); if (is_array($value)) { unset($value['__empty']); - if (!empty($value)) { + if (count($value)) { $value = $this->orderData($value, 'label'); + foreach ($value as $key => $field) { + if (!empty($field['attribute']) && !empty($field['label'])) { + $label = str_replace(" ", "_", trim($field['label'])); + $value[$key]['label'] = strtolower($label); + $value[$key]['attribute'] = $field['attribute']; + } else { + unset($value[$key]); + } + } + $keys = array(); for ($i = 0; $i < count($value); $i++) { $keys[] = 'fields_' . uniqid(); } - foreach ($value as $key => $field) { - $label = str_replace(" ", "_", trim($field['label'])); - $value[$key]['label'] = strtolower($label); - $value[$key]['attribute'] = $field['attribute']; - } - $value = array_combine($keys, array_values($value)); } } - + $this->setValue($value); parent::_beforeSave(); } diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Filter.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Filter.php old mode 100755 new mode 100644 index ae1a635..7d1d305 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Filter.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Filter.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules orderData($value, 'attribute'); foreach ($value as $key => $field) { if (!empty($field['attribute']) && !empty($field['condition'])) { - $attribute = Mage::getModel('eav/entity_attribute')->loadByCode( - 'catalog_product', - $field['attribute'] - ); + $attribute = Mage::getModel('eav/entity_attribute') + ->loadByCode('catalog_product', $field['attribute']); $value[$key]['attribute'] = $field['attribute']; $value[$key]['condition'] = $field['condition']; + $value[$key]['product_type'] = $field['product_type']; $value[$key]['value'] = $field['value']; $value[$key]['type'] = $attribute->getFrontendInput(); } else { diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Shipping.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Shipping.php old mode 100755 new mode 100644 index ceec243..b4a5add --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Shipping.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Backend/Design/Shipping.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '', 'label' => Mage::helper('channable')->__('-- None')); - $position[] = array('value' => 'strip_tags', 'label' => Mage::helper('channable')->__('Strip Tags')); + if (!$this->options) { + $this->options = array( + array('value' => '', 'label' => Mage::helper('channable')->__('-- None')), + array('value' => 'strip_tags', 'label' => Mage::helper('channable')->__('Strip Tags')), + array('value' => 'round', 'label' => Mage::helper('channable')->__('Remove trailing zero\'s')), + ); + } - return $position; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Attribute.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Attribute.php old mode 100755 new mode 100644 index b821eba..a370b16 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Attribute.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Attribute.php @@ -14,61 +14,20 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '', - 'label' => Mage::helper('channable')->__('-- none') - ); - $optionArray[] = array( - 'label' => Mage::helper('channable')->__('- Product ID'), - 'value' => 'entity_id' - ); - $optionArray[] = array( - 'label' => Mage::helper('channable')->__('- Final Price'), - 'value' => 'final_price' - ); - $optionArray[] = array( - 'label' => Mage::helper('channable')->__('- Product Type'), - 'value' => 'type_id' - ); - $optionArray[] = array( - 'label' => Mage::helper('channable')->__('- Attribute Set'), - 'value' => 'attribute_set_id' - ); - - $backendTypes = array('text', 'select', 'textarea', 'date', 'int', 'boolean', 'static', 'varchar', 'decimal'); - $attributes = Mage::getResourceModel('catalog/product_attribute_collection') - ->setOrder('frontend_label', 'ASC') - ->addFieldToFilter('backend_type', $backendTypes); - foreach ($attributes as $attribute) { - if ($attribute->getData('attribute_code') != 'price') { - if ($attribute->getData('frontend_label')) { - $label = str_replace("'", "", $attribute->getData('frontend_label')); - } else { - $label = str_replace("'", "", $attribute->getData('attribute_code')); - } - - $optionArray[] = array( - 'value' => $attribute->getData('attribute_code'), - 'label' => $label, - ); - } - } - - return $optionArray; + return array(); } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Attribute/Abstract.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Attribute/Abstract.php new file mode 100644 index 0000000..1f390a3 --- /dev/null +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Attribute/Abstract.php @@ -0,0 +1,182 @@ +options) { + $options[] = array('value' => '', 'label' => Mage::helper('channable')->__('-- None')); + $options[] = $this->getAttributesArray(); + $this->options = $options; + } + + return $this->options; + } + + /** + * @return array + */ + public function getAttributesArray() + { + $optionArray = $this->getExtraFields(); + $excludes = $this->getExludeAttributes(); + $backendTypes = $this->getBackendTypes(); + $attributes = Mage::getResourceModel('catalog/product_attribute_collection') + ->setOrder('frontend_label', 'ASC') + ->addFieldToFilter('backend_type', $backendTypes) + ->addFieldToFilter('attribute_code', array('nin' => $excludes)); + + foreach ($attributes as $attribute) { + $optionArray[] = array( + 'value' => $attribute->getData('attribute_code'), + 'label' => $this->getLabel($attribute), + ); + } + + usort( + $optionArray, function ($a, $b) { + return strcmp($a["label"], $b["label"]); + } + ); + + return array( + 'label' => Mage::helper('channable')->__('Atttibutes'), + 'value' => $optionArray, + 'optgroup-name' => Mage::helper('channable')->__('Atttibutes') + ); + } + + /** + * @return array + */ + public function getExtraFields() + { + $optionArray = array(); + + $optionArray[] = array( + 'label' => Mage::helper('channable')->__('Product ID'), + 'value' => 'entity_id' + ); + $optionArray[] = array( + 'label' => Mage::helper('channable')->__('Final Price'), + 'value' => 'final_price' + ); + $optionArray[] = array( + 'label' => Mage::helper('channable')->__('Product Type'), + 'value' => 'type_id' + ); + $optionArray[] = array( + 'label' => Mage::helper('channable')->__('Attribute Set ID'), + 'value' => 'attribute_set_id' + ); + $optionArray[] = array( + 'label' => Mage::helper('channable')->__('Minumun Sales Quantity'), + 'value' => 'min_sale_qty' + ); + + return $optionArray; + } + + /** + * @return array + */ + public function getExludeAttributes() + { + return array( + 'compatibility', + 'gallery', + 'installation', + 'language_support', + 'country_of_manufacture', + 'links_title', + 'current_version', + 'custom_design', + 'custom_layout_update', + 'gift_message_available', + 'image', + 'image_label', + 'media_gallery', + 'msrp_display_actual_price_type', + 'msrp_enabled', + 'options_container', + 'price_view', + 'page_layout', + 'samples_title', + 'sku_type', + 'tier_price', + 'url_key', + 'small_image', + 'small_image_label', + 'thumbnail', + 'thumbnail_label', + 'recurring_profile', + 'version_info', + 'category_ids', + 'has_options', + 'required_options', + 'url_path', + 'updated_at', + 'weight_type', + 'sku_type', + 'link_exist', + 'old_id', + 'price_type' + ); + + } + + /** + * @return array + */ + public function getBackendTypes() + { + return array('text', 'select', 'textarea', 'date', 'int', 'boolean', 'static', 'varchar', 'decimal'); + } + + /** + * @param $attribute + * + * @return mixed|string + */ + public function getLabel($attribute) + { + if ($attribute->getData('frontend_label')) { + $label = str_replace("'", "", $attribute->getData('frontend_label')); + } else { + $label = str_replace("'", "", $attribute->getData('attribute_code')); + } + + return trim($label); + } + +} \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Category.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Category.php old mode 100755 new mode 100644 index d3381d9..9ff74ec --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Category.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Category.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules addAttributeToSelect('name')->addPathFilter('^1/[0-9/]+')->load(); - $cats = array(); - foreach ($collection as $category) { - $cat = new stdClass(); - $cat->label = $category->getName(); - $cat->value = $category->getId(); - $cat->level = $category->getLevel(); - $cat->parentid = $category->getParentId(); - $cats[$cat->value] = $cat; - } + if (!$this->options) { + $options = array(); + $collection = Mage::getResourceModel('catalog/category_collection'); + $collection->addAttributeToSelect('name')->addPathFilter('^1/[0-9/]+')->load(); + $cats = array(); - foreach ($cats as $id => $cat) { - if (isset($cats[$cat->parentid])) { - if (!isset($cats[$cat->parentid]->child)) { - $cats[$cat->parentid]->child = array(); - } + foreach ($collection as $category) { + $cat = new stdClass(); + $cat->label = $category->getName(); + $cat->value = $category->getId(); + $cat->level = $category->getLevel(); + $cat->parentid = $category->getParentId(); + $cats[$cat->value] = $cat; + } + + foreach ($cats as $id => $cat) { + if (isset($cats[$cat->parentid])) { + if (!isset($cats[$cat->parentid]->child)) { + $cats[$cat->parentid]->child = array(); + } - $cats[$cat->parentid]->child[] =& $cats[$id]; + $cats[$cat->parentid]->child[] =& $cats[$id]; + } } - } - foreach ($cats as $id => $cat) { - if (!isset($cats[$cat->parentid])) { - $stack = array($cats[$id]); - while (count($stack) > 0) { - $opt = array_pop($stack); - $option = array( - 'label' => ($opt->level > 1 ? str_repeat('- ', $opt->level - 1) : '') . $opt->label, - 'value' => $opt->value - ); - array_push($options, $option); - if (isset($opt->child) && count($opt->child)) { - foreach (array_reverse($opt->child) as $child) { - array_push($stack, $child); + foreach ($cats as $id => $cat) { + if (!isset($cats[$cat->parentid])) { + $stack = array($cats[$id]); + while (count($stack) > 0) { + $opt = array_pop($stack); + $option = array( + 'label' => ($opt->level > 1 ? str_repeat('- ', $opt->level - 1) : '') . $opt->label, + 'value' => $opt->value + ); + array_push($options, $option); + if (isset($opt->child) && count($opt->child)) { + foreach (array_reverse($opt->child) as $child) { + array_push($stack, $child); + } } } } } - } - unset($cats); + $this->options = $options; + } - return $options; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Categorytype.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Categorytype.php old mode 100755 new mode 100644 index 954caf6..20588e7 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Categorytype.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Categorytype.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules 'include', 'label' => Mage::helper('channable')->__('Include by Category')); - $type[] = array('value' => 'exclude', 'label' => Mage::helper('channable')->__('Exclude by Category')); + if (!$this->options) { + $this->options = array( + array('value' => 'include', 'label' => Mage::helper('channable')->__('Include by Category')), + array('value' => 'exclude', 'label' => Mage::helper('channable')->__('Exclude by Category')), + ); + } - return $type; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Conditions.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Conditions.php old mode 100755 new mode 100644 index 8223086..ec85238 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Conditions.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Conditions.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '', 'label' => Mage::helper('channable')->__('')); - $type[] = array('value' => 'eq', 'label' => Mage::helper('channable')->__('Equal')); - $type[] = array('value' => 'neq', 'label' => Mage::helper('channable')->__('Not equal')); - $type[] = array('value' => 'gt', 'label' => Mage::helper('channable')->__('Greater than')); - $type[] = array('value' => 'gteq', 'label' => Mage::helper('channable')->__('Greater than or equal to')); - $type[] = array('value' => 'lt', 'label' => Mage::helper('channable')->__('Less than')); - $type[] = array('value' => 'lteg', 'label' => Mage::helper('channable')->__('Less than or equal to')); - $type[] = array('value' => 'in', 'label' => Mage::helper('channable')->__('In')); - $type[] = array('value' => 'nin', 'label' => Mage::helper('channable')->__('Not in')); - $type[] = array('value' => 'like', 'label' => Mage::helper('channable')->__('Like')); - $type[] = array('value' => 'empty', 'label' => Mage::helper('channable')->__('Empty')); - $type[] = array('value' => 'not-empty', 'label' => Mage::helper('channable')->__('Not Empty')); + if (!$this->options) { + $this->options = array( + array( + 'value' => '', + 'label' => Mage::helper('channable')->__('') + ), + array( + 'value' => 'eq', + 'label' => Mage::helper('channable')->__('Equal') + ), + array( + 'value' => 'neq', + 'label' => Mage::helper('channable')->__('Not equal') + ), + array( + 'value' => 'gt', + 'label' => Mage::helper('channable')->__('Greater than') + ), + array( + 'value' => 'gteq', + 'label' => Mage::helper('channable')->__('Greater than or equal to') + ), + array( + 'value' => 'lt', + 'label' => Mage::helper('channable')->__('Less than') + ), + array( + 'value' => 'lteg', + 'label' => Mage::helper('channable')->__('Less than or equal to') + ), + array( + 'value' => 'in', + 'label' => Mage::helper('channable')->__('In') + ), + array( + 'value' => 'nin', + 'label' => Mage::helper('channable')->__('Not in') + ), + array( + 'value' => 'like', + 'label' => Mage::helper('channable')->__('Like') + ), + array( + 'value' => 'nlike', + 'label' => Mage::helper('channable')->__('Like') + ), + array( + 'value' => 'empty', + 'label' => Mage::helper('channable')->__('Empty') + ), + array( + 'value' => 'not-empty', + 'label' => Mage::helper('channable')->__('Not Empty') + ), + array( + 'value' => 'finset', + 'label' => Mage::helper('channable')->__('In Set') + ), + ); + } - return $type; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Configurable.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Configurable.php old mode 100755 new mode 100644 index 83e3549..167aae5 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Configurable.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Configurable.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules getFeedAttributes(); - $attributesSkip = array('id', 'parent_id', 'price', 'stock', 'stock_status', 'visibility', 'status', 'type'); - $att = array(); - foreach ($attributes as $key => $attribute) { - if (!in_array($key, $attributesSkip)) { - $att[] = array('value' => $key, 'label' => $key); + 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'); + $att = array(); + foreach ($attributes as $key => $attribute) { + if (!in_array($key, $attributesSkip) && !empty($key)) { + $label = !empty($attribute['label']) ? $attribute['label'] : $key; + $att[$label] = array('value' => $key, 'label' => $label); + } } + + $this->options = $att; } - return $att; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Countries.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Countries.php old mode 100755 new mode 100644 index 1dcba3f..161cde6 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Countries.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Countries.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '', 'label' => Mage::helper('channable')->__('-- All Countries')); - $source = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray(); - unset($source[0]); + if (!$this->options) { - return array_merge($countries, $source); - } + $countries = array(); + $countries[] = array('value' => '', 'label' => Mage::helper('channable')->__('-- All Countries')); + $source = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray(); + unset($source[0]); + + $this->options = array_merge($countries, $source); + } + + return $this->options; + } } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Images.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Images.php old mode 100755 new mode 100644 index 523bc7d..195e445 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Images.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Images.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '', 'label' => Mage::helper('channable')->__('Only Base Image')); - $type[] = array('value' => 'all', 'label' => Mage::helper('channable')->__('All Images')); + if (!$this->options) { + $this->options = array( + array('value' => '', 'label' => Mage::helper('channable')->__('Only Base Image')), + array('value' => 'all', 'label' => Mage::helper('channable')->__('All Images')), + ); + } - return $type; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Mainimage.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Mainimage.php old mode 100755 new mode 100644 index 3d2131d..eec8535 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Mainimage.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Mainimage.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules addFieldToFilter( - 'frontend_input', - 'media_image' - ); - $type = array(); - $type[] = array('value' => '', 'label' => Mage::helper('channable')->__('Use default')); - foreach ($attributes as $attribute) { - $type[] = array( - 'value' => $attribute->getData('attribute_code'), - 'label' => str_replace("'", "", $attribute->getData('frontend_label')) + if (!$this->options) { + $attributes = Mage::getResourceModel('catalog/product_attribute_collection') + ->addFieldToFilter('frontend_input', 'media_image'); + + $this->options[] = array( + 'value' => '', + 'label' => Mage::helper('channable')->__('Use default') ); - } - $type[] = array('value' => 'first', 'label' => Mage::helper('channable')->__('First Image')); - $type[] = array('value' => 'last', 'label' => Mage::helper('channable')->__('Last Image')); + foreach ($attributes as $attribute) { + $this->options[] = array( + 'value' => $attribute->getData('attribute_code'), + 'label' => str_replace("'", "", $attribute->getData('frontend_label')) + ); + } - return $type; - } + $this->options[] = array( + 'value' => 'first', + 'label' => Mage::helper('channable')->__('First Image') + ); + $this->options[] = array( + 'value' => 'last', + 'label' => Mage::helper('channable')->__('Last Image') + ); + } + return $this->options; + } } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Name.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Name.php old mode 100755 new mode 100644 index 812a359..e83f057 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Name.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Name.php @@ -14,77 +14,64 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '', 'label' => Mage::helper('channable')->__('-- none')); - $entityTypeId = Mage::getModel('eav/entity_type')->loadByCode('catalog_product')->getEntityTypeId(); - $backendTypes = array('text','varchar','static'); - - $attributes = Mage::getModel('eav/entity_attribute')->getCollection() - ->addFilter('entity_type_id', $entityTypeId) - ->setOrder('attribute_code', 'ASC'); - - foreach ($attributes as $attribute) { - if (in_array($attribute->getBackendType(), $backendTypes)) { - if ($attribute->getFrontendLabel()) { - if (!in_array($attribute->getAttributeCode(), $this->_ignore)) { - $options[] = array( - 'value' => $attribute->getAttributeCode(), - 'label' => $attribute->getFrontendLabel() - ); - } - } - } - } - - $options[] = array('value' => 'use_custom', 'label' => Mage::helper('channable')->__('-- Custom:')); - - return $options; + return array('text', 'textarea', 'varchar', 'static'); } + /** + * @return array + */ + public function getExludeAttributes() + { + return array( + 'compatibility', + 'gallery', + 'installation', + 'language_support', + 'country_of_manufacture', + 'links_title', + 'current_version', + 'custom_design', + 'custom_layout_update', + 'gift_message_available', + 'image', + 'image_label', + 'media_gallery', + 'msrp_display_actual_price_type', + 'msrp_enabled', + 'options_container', + 'price_view', + 'page_layout', + 'samples_title', + 'sku_type', + 'tier_price', + 'url_key', + 'small_image', + 'small_image_label', + 'thumbnail', + 'thumbnail_label', + 'recurring_profile', + 'version_info', + 'meta_title', + 'meta_keyword', + 'category_ids', + 'has_options', + 'required_options', + 'url_path', + 'updated_at' + ); + } } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Pricemodel.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Pricemodel.php old mode 100755 new mode 100644 index d78c216..ff7b43e --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Pricemodel.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Pricemodel.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '', 'label' => Mage::helper('adminhtml')->__('Use default price')); - $type[] = array('value' => 'min', 'label' => Mage::helper('adminhtml')->__('Use minimum price')); - $type[] = array('value' => 'max', 'label' => Mage::helper('adminhtml')->__('Use maximum price')); - $type[] = array('value' => 'total', 'label' => Mage::helper('adminhtml')->__('Use total price')); + if (!$this->options) { + $this->options = array( + array('value' => '', 'label' => Mage::helper('adminhtml')->__('Use default price')), + array('value' => 'min', 'label' => Mage::helper('adminhtml')->__('Use minimum price')), + array('value' => 'max', 'label' => Mage::helper('adminhtml')->__('Use maximum price')), + array('value' => 'total', 'label' => Mage::helper('adminhtml')->__('Use total price')), + ); + } - return $type; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Producttypes.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Producttypes.php new file mode 100644 index 0000000..93d2c37 --- /dev/null +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Producttypes.php @@ -0,0 +1,47 @@ + + * @copyright Copyright (c) 2018 (http://www.magmodules.eu) + * @license https://www.magmodules.eu/terms.html Single Service License + */ + +class Magmodules_Channable_Model_Adminhtml_System_Config_Source_Producttypes +{ + + /** + * Options array + * + * @var array + */ + public $options = null; + + /** + * @return array + */ + public function toOptionArray() + { + if (!$this->options) { + $this->options = array( + array('value' => '', 'label' => Mage::helper('channable')->__('Simple & Parent Products')), + array('value' => 'simple', 'label' => Mage::helper('channable')->__('Only Simple Products')), + array('value' => 'parent', 'label' => Mage::helper('channable')->__('Only Parent Products')), + + ); + } + + return $this->options; + } +} \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Selectattribute.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Selectattribute.php old mode 100755 new mode 100644 index 65fb390..ad89f71 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Selectattribute.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Selectattribute.php @@ -14,53 +14,37 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '', 'label' => Mage::helper('channable')->__('-- none')); - $entityTypeId = Mage::getModel('eav/entity_type')->loadByCode('catalog_product')->getEntityTypeId(); - $backendTypes = array('text','varchar','static'); - - $attributes = Mage::getModel('eav/entity_attribute')->getCollection() - ->addFilter('entity_type_id', $entityTypeId) - ->setOrder('attribute_code', 'ASC'); - - foreach ($attributes as $attribute) { - if (in_array($attribute->getBackendType(), $backendTypes)) { - if ($attribute->getFrontendLabel()) { - if (!in_array($attribute->getAttributeCode(), $this->_ignore)) { - $options[] = array( - 'value' => $attribute->getAttributeCode(), - 'label' => $attribute->getFrontendLabel() - ); - } - } - } - } - - return $options; + return array('text', 'varchar', 'static'); } + /** + * @return array + */ + public function getExludeAttributes() + { + return array( + 'ebizmarts_mark_visited', + 'is_recurring', + 'links_purchased_separately', + 'price_view', + 'status', + 'tax_class_id', + 'visibility', + 'shipment_type', + ); + } } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Shipping.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Shipping.php old mode 100755 new mode 100644 index 430c8fd..8a39f9d --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Shipping.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Shipping.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules 'price', 'label' => Mage::helper('channable')->__('Price')); - $type[] = array('value' => 'weight', 'label' => Mage::helper('channable')->__('Weight')); + if (!$this->options) { + $this->options = array( + array('value' => 'price', 'label' => Mage::helper('adminhtml')->__('Based on product price')), + array('value' => 'weight', 'label' => Mage::helper('adminhtml')->__('Based on product weight')), + ); + } - return $type; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Tax.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Tax.php old mode 100755 new mode 100644 index 967f658..b4776ea --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Tax.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Tax.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '', 'label' => Mage::helper('channable')->__('No')); - $position[] = array('value' => 'incl', 'label' => Mage::helper('channable')->__('Force including Tax')); - $position[] = array('value' => 'excl', 'label' => Mage::helper('channable')->__('Force excluding Tax')); + if (!$this->options) { + $this->options = array( + array('value' => '', 'label' => Mage::helper('channable')->__('No')), + array('value' => 'incl', 'label' => Mage::helper('channable')->__('Force including Tax')), + array('value' => 'excl', 'label' => Mage::helper('channable')->__('Force excluding Tax')), + ); + } - return $position; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Textattribute.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Textattribute.php old mode 100755 new mode 100644 index d0d24e5..e96d531 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Textattribute.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Textattribute.php @@ -14,74 +14,64 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '', 'label' => Mage::helper('channable')->__('-- none')); - $entityTypeId = Mage::getModel('eav/entity_type')->loadByCode('catalog_product')->getEntityTypeId(); - $backendTypes = array('text', 'varchar', 'static'); - - $attributes = Mage::getModel('eav/entity_attribute')->getCollection() - ->addFilter('entity_type_id', $entityTypeId) - ->addFilter('backend_type', $backendTypes) - ->setOrder('attribute_code', 'ASC'); - - foreach ($attributes as $attribute) { - if ($attribute->getFrontendLabel()) { - if (!in_array($attribute->getAttributeCode(), $this->_ignore)) { - $options[] = array( - 'value' => $attribute->getAttributeCode(), - 'label' => $attribute->getFrontendLabel() - ); - } - } - } - - return $options; + return array('text', 'varchar', 'static'); } + /** + * @return array + */ + public function getExludeAttributes() + { + return array( + 'compatibility', + 'gallery', + 'installation', + 'language_support', + 'country_of_manufacture', + 'links_title', + 'current_version', + 'custom_design', + 'custom_layout_update', + 'gift_message_available', + 'image', + 'image_label', + 'media_gallery', + 'msrp_display_actual_price_type', + 'msrp_enabled', + 'options_container', + 'price_view', + 'page_layout', + 'samples_title', + 'sku_type', + 'tier_price', + 'url_key', + 'small_image', + 'small_image_label', + 'thumbnail', + 'thumbnail_label', + 'recurring_profile', + 'version_info', + 'meta_title', + 'meta_keyword', + 'category_ids', + 'has_options', + 'required_options', + 'url_path', + 'updated_at' + ); + } } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Type.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Type.php old mode 100755 new mode 100644 index ca79815..e1401ea --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Type.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Type.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '', 'label' => Mage::helper('channable')->__('Disabled')); - $type[] = array('value' => 'fixed', 'label' => Mage::helper('channable')->__('Static')); - $type[] = array('value' => 'attribute', 'label' => Mage::helper('channable')->__('Use Attribute')); + if (!$this->options) { + $this->options = array( + array('value' => '', 'label' => Mage::helper('channable')->__('Disabled')), + array('value' => 'fixed', 'label' => Mage::helper('channable')->__('Static Values')), + array('value' => 'attribute', 'label' => Mage::helper('channable')->__('Use Attribute')), + ); + } - return $type; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Visibility.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Visibility.php old mode 100755 new mode 100644 index 750bd79..5129b37 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Visibility.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Visibility.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules '1', 'label' => Mage::helper('adminhtml')->__('Not Visible Individually')); - $type[] = array('value' => '2', 'label' => Mage::helper('adminhtml')->__('Catalog')); - $type[] = array('value' => '3', 'label' => Mage::helper('adminhtml')->__('Search')); - $type[] = array('value' => '4', 'label' => Mage::helper('adminhtml')->__('Catalog, Search')); + if (!$this->options) { + $this->options = array( + array('value' => '1', 'label' => Mage::helper('adminhtml')->__('Not Visible Individually')), + array('value' => '2', 'label' => Mage::helper('adminhtml')->__('Catalog')), + array('value' => '3', 'label' => Mage::helper('adminhtml')->__('Search')), + array('value' => '4', 'label' => Mage::helper('adminhtml')->__('Catalog, Search')), + ); + } - return $type; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Weight.php b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Weight.php old mode 100755 new mode 100644 index f9d7062..56afae4 --- a/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Weight.php +++ b/app/code/community/Magmodules/Channable/Model/Adminhtml/System/Config/Source/Weight.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules 'lb', 'label' => Mage::helper('adminhtml')->__('Pounds (lb)')); - $type[] = array('value' => 'oz', 'label' => Mage::helper('adminhtml')->__('Ounces (oz)')); - $type[] = array('value' => 'g', 'label' => Mage::helper('adminhtml')->__('Grams (g)')); - $type[] = array('value' => 'kg', 'label' => Mage::helper('adminhtml')->__('Kilograms (kg)')); + if (!$this->options) { + $this->options = array( + array('value' => 'lb', 'label' => Mage::helper('adminhtml')->__('Pounds (lb)')), + array('value' => 'oz', 'label' => Mage::helper('adminhtml')->__('Ounces (oz)')), + array('value' => 'g', 'label' => Mage::helper('adminhtml')->__('Grams (g)')), + array('value' => 'kg', 'label' => Mage::helper('adminhtml')->__('Kilograms (kg)')), + ); + } - return $type; + return $this->options; } - } \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/Model/Channable.php b/app/code/community/Magmodules/Channable/Model/Channable.php old mode 100755 new mode 100644 index 1eb02b8..c7eec7a --- a/app/code/community/Magmodules/Channable/Model/Channable.php +++ b/app/code/community/Magmodules/Channable/Model/Channable.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules helper = Mage::helper('channable'); + } + + /** + * @param $storeId + * @param $timeStart + * @param int $page * - * @return array|bool + * @return array + * @throws Mage_Core_Exception */ - public function generateFeed($storeId, $limit = '', $timeStart, $page = 1) + public function generateFeed($storeId, $timeStart, $page = 1) { $this->setMemoryLimit($storeId); - $config = $this->getFeedConfig($storeId); $this->cleanItemUpdates($storeId, $page); - $products = $this->getProducts($config, $limit, $page); - $parents = $this->getParents($products, $config); - $prices = Mage::helper('channable')->getTypePrices($config, $parents); - $parentAttributes = Mage::helper('channable')->getConfigurableAttributesAsArray($parents, $config); - if ($feed = $this->getFeedData($products, $parents, $config, $parentAttributes, $timeStart, $prices, $page)) { - return $feed; + $config = $this->getFeedConfig($storeId); + + $productCollection = $this->getProducts($config); + $totalCount = $this->getCollectionCountWithFilters($productCollection); + + if (($config['limit'] > 0) && empty($productId)) { + $productCollection->setPage($page, $config['limit'])->getCurPage(); + $pages = ceil($totalCount / $config['limit']); + } else { + $pages = 1; } - return false; + $products = $productCollection->load(); + $parentRelations = $this->helper->getParentsFromCollection($products, $config); + $parents = $this->getParents($parentRelations, $config); + $prices = $this->helper->getTypePrices($config, $parents); + $parentAttributes = $this->helper->getConfigurableAttributesAsArray($parents, $config); + + if ($feed = $this->getFeedData($products, $parents, $config, $parentAttributes, $prices, $parentRelations)) { + $returnFeed = array(); + $returnFeed['config'] = $this->getFeedHeader($config, $totalCount, $timeStart, count($feed), $page, $pages); + $returnFeed['products'] = $feed; + return $returnFeed; + } else { + $returnFeed = array(); + $returnFeed['config'] = $this->getFeedHeader($config, $totalCount, $timeStart, 0, $page, $pages); + $returnFeed['products'] = $feed; + return $returnFeed; + } } /** @@ -64,34 +96,44 @@ protected function setMemoryLimit($storeId) /** * @param $storeId + * @param $page + */ + protected function cleanItemUpdates($storeId, $page) + { + if (empty($page)) { + if (Mage::helper('core')->isModuleEnabled('Magmodules_Channableapi')) { + Mage::getModel('channableapi/items')->cleanItemStore($storeId); + } + } + } + + /** + * @param $storeId + * @param string $type * * @return array */ - public function getFeedConfig($storeId) + public function getFeedConfig($storeId, $type = 'xml') { $config = array(); - $feed = Mage::helper('channable'); - $websiteId = Mage::app()->getStore($storeId)->getWebsiteId(); + $store = Mage::getModel('core/store')->load($storeId); + $websiteId = $store->getWebsiteId(); + $websiteName = Mage::getModel('core/website')->load($websiteId)->getName(); + $attribute = Mage::getResourceModel('eav/entity_attribute'); - // DEFAULTS $config['store_id'] = $storeId; - $config['website_name'] = $feed->cleanData( - Mage::getModel('core/website')->load($websiteId)->getName(), - 'striptags' - ); - $config['website_url'] = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); - $config['media_url'] = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); + $config['website_id'] = $websiteId; + $config['website_name'] = $this->helper->cleanData($websiteName, 'striptags'); + $config['website_url'] = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK); + $config['media_url'] = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA); $config['media_image_url'] = $config['media_url'] . 'catalog' . DS . 'product'; - $config['media_attributes'] = $feed->getMediaAttributes(); + $config['media_attributes'] = $this->helper->getMediaAttributes(); $config['limit'] = Mage::getStoreConfig('channable/connect/max_products', $storeId); $config['version'] = (string)Mage::getConfig()->getNode()->modules->Magmodules_Channable->version; - $config['media_gallery_id'] = Mage::getResourceModel('eav/entity_attribute')->getIdByCode( - 'catalog_product', - 'media_gallery' - ); + $config['media_gallery_id'] = $attribute->getIdByCode('catalog_product', 'media_gallery'); $config['filters'] = @unserialize(Mage::getStoreConfig('channable/filter/advanced', $storeId)); - $config['product_url_suffix'] = $feed->getProductUrlSuffix($storeId); + $config['product_url_suffix'] = $this->helper->getProductUrlSuffix($storeId); $config['filter_enabled'] = Mage::getStoreConfig('channable/filter/category_enabled', $storeId); $config['filter_cat'] = Mage::getStoreConfig('channable/filter/categories', $storeId); $config['filter_type'] = Mage::getStoreConfig('channable/filter/category_type', $storeId); @@ -99,7 +141,6 @@ public function getFeedConfig($storeId) $config['hide_no_stock'] = Mage::getStoreConfig('channable/filter/stock', $storeId); $config['conf_enabled'] = Mage::getStoreConfig('channable/data/conf_enabled', $storeId); $config['conf_fields'] = Mage::getStoreConfig('channable/data/conf_fields', $storeId); - $config['parent_att'] = $this->getParentAttributeSelection($config['conf_fields']); $config['stock_bundle'] = Mage::getStoreConfig('channable/data/stock_bundle', $storeId); $config['conf_switch_urls'] = Mage::getStoreConfig('channable/data/conf_switch_urls', $storeId); $config['simple_price'] = Mage::getStoreConfig('channable/data/simple_price', $storeId); @@ -116,17 +157,24 @@ public function getFeedConfig($storeId) $config['delivery_out_be'] = Mage::getStoreConfig('channable/data/delivery_out_be', $storeId); $config['images'] = Mage::getStoreConfig('channable/data/images', $storeId); $config['default_image'] = Mage::getStoreConfig('channable/data/default_image', $storeId); - $config['skip_validation'] = false; $config['weight'] = Mage::getStoreConfig('channable/data/weight', $storeId); $config['weight_units'] = Mage::getStoreConfig('channable/data/weight_units', $storeId); $config['price_scope'] = Mage::getStoreConfig('catalog/price/scope'); $config['price_add_tax'] = Mage::getStoreConfig('channable/data/add_tax', $storeId); $config['price_add_tax_perc'] = Mage::getStoreConfig('channable/data/tax_percentage', $storeId); $config['force_tax'] = Mage::getStoreConfig('channable/data/force_tax', $storeId); - $config['currency'] = Mage::app()->getStore($storeId)->getCurrentCurrencyCode(); - $config['base_currency_code'] = Mage::app()->getStore($storeId)->getBaseCurrencyCode(); - $config['markup'] = Mage::helper('channable')->getPriceMarkup($config); - $config['use_tax'] = Mage::helper('channable')->getTaxUsage($config); + $config['currency'] = $store->getCurrentCurrencyCode(); + $config['base_currency_code'] = $store->getBaseCurrencyCode(); + $config['markup'] = $this->helper->getPriceMarkup($config); + $config['use_tax'] = $this->helper->getTaxUsage($config); + $config['skip_validation'] = false; + + if($type != 'API') { + $config['category_exclude'] = 'channable_exclude'; + $config['category_data'] = $this->helper->getCategoryData($config, $storeId); + } + + $config['bypass_flat'] = Mage::getStoreConfig('channable/server/bypass_flat'); if (Mage::helper('core')->isModuleEnabled('Magmodules_Channableapi')) { $config['item_updates'] = Mage::getStoreConfig('channable_api/item/enabled', $storeId); @@ -136,9 +184,8 @@ public function getFeedConfig($storeId) $config['shipping_prices'] = @unserialize(Mage::getStoreConfig('channable/advanced/shipping_price', $storeId)); $config['shipping_method'] = Mage::getStoreConfig('channable/advanced/shipping_method', $storeId); - $config['field'] = $this->getFeedAttributes($config, $storeId); - $config['category_exclude'] = 'channable_exclude'; - $config['category_data'] = $feed->getCategoryData($config, $storeId); + $config['field'] = $this->getFeedAttributes($storeId, $type, $config); + $config['parent_att'] = $this->getParentAttributeSelection($config['field']); return $config; } @@ -149,7 +196,7 @@ public function getFeedConfig($storeId) * * @return mixed */ - public function getFeedAttributes($config = '', $storeId = 0) + public function getFeedAttributes($storeId = 0, $type = 'xml', $config = '') { $attributes = array(); $attributes['id'] = array( @@ -160,18 +207,6 @@ public function getFeedAttributes($config = '', $storeId = 0) 'label' => 'name', 'source' => Mage::getStoreConfig('channable/data/name', $storeId) ); - $attributes['description'] = array( - 'label' => 'description', - 'source' => Mage::getStoreConfig('channable/data/description', $storeId) - ); - $attributes['product_url'] = array( - 'label' => 'url', - 'source' => '' - ); - $attributes['image_link'] = array( - 'label' => 'image', - 'source' => Mage::getStoreConfig('channable/data/default_image', $storeId) - ); $attributes['price'] = array( 'label' => 'price', 'source' => '' @@ -180,35 +215,10 @@ public function getFeedAttributes($config = '', $storeId = 0) 'label' => 'sku', 'source' => Mage::getStoreConfig('channable/data/sku', $storeId) ); - $attributes['brand'] = array( - 'label' => 'brand', - 'source' => Mage::getStoreConfig('channable/data/brand', $storeId) - ); - $attributes['size'] = array( - 'label' => 'size', - 'source' => Mage::getStoreConfig('channable/data/size', $storeId) - ); - $attributes['color'] = array( - 'label' => 'color', - 'source' => Mage::getStoreConfig('channable/data/color', $storeId) - ); - $attributes['material'] = array( - 'label' => 'material', - 'source' => Mage::getStoreConfig('channable/data/material', $storeId) - ); - $attributes['gender'] = array( - 'label' => 'gender', - 'source' => Mage::getStoreConfig('channable/data/gender', $storeId) - ); - $attributes['ean'] = array( + $attributes['ean'] = array( 'label' => 'ean', 'source' => Mage::getStoreConfig('channable/data/ean', $storeId) ); - $attributes['categories'] = array( - 'label' => 'categories', - 'source' => '', - 'parent' => 1 - ); $attributes['type'] = array( 'label' => 'type', 'source' => 'type_id' @@ -227,15 +237,10 @@ public function getFeedAttributes($config = '', $storeId = 0) 'source' => 'entity_id', 'parent' => 1 ); - $attributes['weight'] = array( - 'label' => 'weight', - 'source' => '' - ); $attributes['is_in_stock'] = array( 'label' => 'is_in_stock', 'source' => 'is_in_stock' ); - if (Mage::getStoreConfig('channable/data/stock', $storeId)) { $attributes['stock'] = array( 'label' => 'qty', @@ -244,82 +249,118 @@ public function getFeedAttributes($config = '', $storeId = 0) ); } - if (Mage::getStoreConfig('channable/data/delivery', $storeId) == 'attribute') { - $attributes['delivery'] = array( - 'label' => 'delivery', - 'source' => Mage::getStoreConfig('channable/data/delivery_att', $storeId) - ); - } - - if (Mage::getStoreConfig('channable/data/delivery_be', $storeId) == 'attribute') { - $attributes['delivery_be'] = array( - 'label' => 'delivery_be', - 'source' => Mage::getStoreConfig('channable/data/delivery_att_be', $storeId) - ); - } - + if($type != 'API') { + $attributes['description'] = array( + 'label' => 'description', + 'source' => Mage::getStoreConfig('channable/data/description', $storeId) + ); + $attributes['product_url'] = array( + 'label' => 'url', + 'source' => '' + ); + $attributes['image_link'] = array( + 'label' => 'image', + 'source' => Mage::getStoreConfig('channable/data/default_image', $storeId) + ); + $attributes['brand'] = array( + 'label' => 'brand', + 'source' => Mage::getStoreConfig('channable/data/brand', $storeId) + ); + $attributes['size'] = array( + 'label' => 'size', + 'source' => Mage::getStoreConfig('channable/data/size', $storeId) + ); + $attributes['color'] = array( + 'label' => 'color', + 'source' => Mage::getStoreConfig('channable/data/color', $storeId) + ); + $attributes['material'] = array( + 'label' => 'material', + 'source' => Mage::getStoreConfig('channable/data/material', $storeId) + ); + $attributes['gender'] = array( + 'label' => 'gender', + 'source' => Mage::getStoreConfig('channable/data/gender', $storeId) + ); + $attributes['categories'] = array( + 'label' => 'categories', + 'source' => '', + 'parent' => 1 + ); + $attributes['weight'] = array( + 'label' => 'weight', + 'source' => '' + ); + if (Mage::getStoreConfig('channable/data/delivery', $storeId) == 'attribute') { + $attributes['delivery'] = array( + 'label' => 'delivery', + 'source' => Mage::getStoreConfig('channable/data/delivery_att', $storeId) + ); + } + if (Mage::getStoreConfig('channable/data/delivery_be', $storeId) == 'attribute') { + $attributes['delivery_be'] = array( + 'label' => 'delivery_be', + 'source' => Mage::getStoreConfig('channable/data/delivery_att_be', $storeId) + ); + } + } + if ($extraFields = @unserialize(Mage::getStoreConfig('channable/advanced/extra', $storeId))) { + $i = 1; foreach ($extraFields as $extraField) { - $attributes[$extraField['attribute']] = array( + $attributes['extra-'.$i] = array( 'label' => $extraField['label'], 'source' => $extraField['attribute'], 'action' => '' ); + $i++; } } - return Mage::helper('channable')->addAttributeData($attributes, $config); - } - - /** - * @param $storeId - * @param $page - */ - protected function cleanItemUpdates($storeId, $page) - { - if (empty($page)) { - if (Mage::helper('core')->isModuleEnabled('Magmodules_Channableapi')) { - Mage::getModel('channableapi/items')->cleanItemStore($storeId); - } + if ($type != 'config') { + $attributes = $this->helper->addAttributeData($attributes, $config); } + + return $attributes; } /** - * @param $products - * @param $parents - * @param $config - * @param $parentAttributes - * @param $timeStart - * @param $prices - * @param $page + * @param Mage_Catalog_Model_Resource_Product_Collection $products + * @param Mage_Catalog_Model_Resource_Product_Collection $parents + * @param $config + * @param $parentAttributes + * @param $prices + * @param $parentRelations * * @return array */ - public function getFeedData($products, $parents, $config, $parentAttributes, $timeStart, $prices, $page) + public function getFeedData($products, $parents, $config, $parentAttributes, $prices, $parentRelations) { - $count = $this->getProducts($config, '', '', 'count'); - foreach ($products as $product) { + $feed = array(); - if ($parentId = Mage::helper('channable')->getParentData($product, $config)) { - $parent = $parents->getItemById($parentId); - } else { - $parent = ''; + foreach ($products as $product) { + $parent = null; + if (!empty($parentRelations[$product->getEntityId()])) { + foreach ($parentRelations[$product->getEntityId()] as $parentId) { + if ($parent = $parents->getItemById($parentId)) { + continue; + } + } } - $productData = Mage::helper('channable')->getProductDataRow($product, $config, $parent, $parentAttributes); - + $productData = $this->helper->getProductDataRow($product, $config, $parent, $parentAttributes); if ($productData) { + $productRow = array(); foreach ($productData as $key => $value) { if (!is_array($value)) { $productRow[$key] = $value; } } - if ($extraData = $this->getExtraDataFields($productData, $config, $product, $prices)) { $productRow = array_merge($productRow, $extraData); } - $feed['products'][] = $productRow; + $feed[] = $productRow; if ($config['item_updates']) { $this->processItemUpdates($productRow, $config['store_id']); } @@ -328,16 +369,7 @@ public function getFeedData($products, $parents, $config, $parentAttributes, $ti } } - if (!empty($feed)) { - $returnFeed = array(); - $returnFeed['config'] = $this->getFeedHeader($config, $count, $timeStart, count($feed['products']), $page); - $returnFeed['products'] = $feed['products']; - return $returnFeed; - } else { - $returnFeed = array(); - $returnFeed['config'] = $this->getFeedHeader($config, $count, $timeStart, '', $page); - return $returnFeed; - } + return $feed; } /** @@ -357,7 +389,6 @@ public function getExtraDataFields($productData, $config, $product, $prices) } else { $itemGroupId = ''; } - if ($priceData = $this->getPrices( $productData['price'], $prices, @@ -392,11 +423,11 @@ public function getExtraDataFields($productData, $config, $product, $prices) } /** - * @param $data - * @param $confPrices - * @param $product - * @param $currency - * @param $itemGroupId + * @param $data + * @param $confPrices + * @param Mage_Catalog_Model_Product $product + * @param $currency + * @param $itemGroupId * * @return array */ @@ -416,8 +447,12 @@ public function getPrices($data, $confPrices, $product, $currency, $itemGroupId) } } else { $prices['price'] = $data['price']; - $prices['min_price'] = $data['min_price']; - $prices['max_price'] = $data['max_price']; + if(isset($data['min_price'])) { + $prices['min_price'] = $data['min_price']; + } + if(isset($data['max_price'])) { + $prices['max_price'] = $data['max_price']; + } $prices['special_price'] = ''; $prices['special_price_from'] = ''; $prices['special_price_to'] = ''; @@ -438,44 +473,47 @@ public function getPrices($data, $confPrices, $product, $currency, $itemGroupId) } /** - * @param $productData - * @param $config - * @param $product + * @param $productData + * @param $config + * @param Mage_Catalog_Model_Product $product * * @return array */ public function getStockData($productData, $config, $product) { $stockData = array(); - $stockData['is_in_stock'] = $productData['is_in_stock']; - if (!empty($productData['qty'])) { - $stockData['qty'] = $productData['qty']; - } else { + if (!isset($productData['qty'])) { $stockData['qty'] = (string)'0'; } - if ($product->getUseConfigManageStock()) { - $stockData['manage_stock'] = (string)$config['stock_manage']; - } else { - $stockData['manage_stock'] = (string)$product->getManageStock(); + if (!isset($productData['manage_stock'])) { + if ($product->getUseConfigManageStock()) { + $stockData['manage_stock'] = (string)$config['stock_manage']; + } else { + $stockData['manage_stock'] = (string)$product->getManageStock(); + } } - if (!empty($product['min_sale_qty'])) { - $stockData['min_sale_qty'] = (string)round($product['min_sale_qty']); - } else { - $stockData['min_sale_qty'] = '1'; + if (empty($productData['min_sale_qty'])) { + if (!empty($product['min_sale_qty'])) { + $stockData['min_sale_qty'] = (string)round($product['min_sale_qty']); + } else { + $stockData['min_sale_qty'] = '1'; + } } - if ($product->getUseEnableQtyIncrements()) { - if (!empty($config['use_qty_increments'])) { - $stockData['qty_increments'] = (string)$config['qty_increments']; - } - } else { - if ($product->getUseConfigQtyIncrements()) { - $stockData['qty_increments'] = (string)$config['qty_increments']; + if (empty($productData['qty_increments'])) { + if ($product->getUseEnableQtyIncrements()) { + if (!empty($config['use_qty_increments'])) { + $stockData['qty_increments'] = (string)$config['qty_increments']; + } } else { - $stockData['qty_increments'] = round($product['qty_increments']); + if ($product->getUseConfigQtyIncrements()) { + $stockData['qty_increments'] = (string)$config['qty_increments']; + } else { + $stockData['qty_increments'] = round($product['qty_increments']); + } } } @@ -651,12 +689,12 @@ public function processItemUpdates($productRow, $storeId) * @param $timeStart * @param int $productCount * @param int $page + * @param int $pages * * @return array */ - public function getFeedHeader($config, $count, $timeStart, $productCount = 0, $page = 1) + public function getFeedHeader($config, $count, $timeStart, $productCount = 0, $page = 1, $pages = 1) { - $pages = (($config['limit']) && ($count > $config['limit'])) ? ceil($count / $config['limit']) : 1; $header = array(); $header['system'] = 'Magento'; $header['extension'] = 'Magmodules_Channable'; @@ -669,6 +707,7 @@ public function getFeedHeader($config, $count, $timeStart, $productCount = 0, $p $header['products_pages'] = $pages; $header['current_page'] = ($page) ? $page : 1; $header['processing_time'] = number_format((microtime(true) - $timeStart), 4); + if ($header['products_pages'] > $header['current_page']) { $header['next_page'] = 'true'; } else { diff --git a/app/code/community/Magmodules/Channable/Model/Common.php b/app/code/community/Magmodules/Channable/Model/Common.php old mode 100755 new mode 100644 index 5819a1c..8c42cfd --- a/app/code/community/Magmodules/Channable/Model/Common.php +++ b/app/code/community/Magmodules/Channable/Model/Common.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules setStore($storeId); - $collection->addStoreFilter($storeId); - $collection->addFinalPrice(); - $collection->addUrlRewrite(); + $websiteId = $config['website_id']; + + if (!empty($config['bypass_flat'])) { + $collection = Mage::getModel('channable/resource_product_collection'); + } else { + $collection = Mage::getResourceModel('catalog/product_collection'); + } + + /** @var Mage_Catalog_Model_Resource_Product_Collection $collection */ + $collection->setStore($storeId) + ->addStoreFilter($storeId) + ->addUrlRewrite() + ->addAttributeToFilter('status', 1); + + if (!empty($productIds)) { + $collection->addAttributeToFilter('entity_id', array('in' => $productIds)); + } if (!empty($config['filter_enabled'])) { $filterType = $config['filter_type']; @@ -54,15 +65,6 @@ public function getProducts($config, $limit = '', $page = 1, $type = '') } } - $collection->addAttributeToFilter('status', 1); - - if (($limit) && ($type != 'count')) { - $collection->setPage($page, $limit)->getCurPage(); - if ($collection->getLastPageNumber() < $page) { - return array(); - } - } - if (empty($config['conf_enabled'])) { $collection->addAttributeToFilter('visibility', array('in' => array(2, 3, 4))); } @@ -75,110 +77,180 @@ public function getProducts($config, $limit = '', $page = 1, $type = '') Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection); } - if ($type != 'count') { - $attributes = $this->getDefaultAttributes(); - - if (!empty($config['filter_exclude'])) { - $attributes[] = $config['filter_exclude']; - } - - foreach ($config['field'] as $field) { - if (!empty($field['source'])) { - $attributes[] = $field['source']; - } - } - - if (!empty($config['delivery_att'])) { - $attributes[] = $config['delivery_att']; - } - - if (!empty($config['delivery_att_be'])) { - $attributes[] = $config['delivery_att_be']; - } - - if (!empty($config['media_attributes'])) { - foreach ($config['media_attributes'] as $mediaAtt) { - $attributes[] = $mediaAtt; - } - } + $attributes = $this->getAttributes($config['field']); + $collection->addAttributeToSelect($attributes); + + $collection->joinTable( + 'cataloginventory/stock_item', 'product_id=entity_id', array( + "qty" => "qty", + "is_in_stock" => "is_in_stock", + "manage_stock" => "manage_stock", + "use_config_manage_stock" => "use_config_manage_stock", + "min_sale_qty" => "min_sale_qty", + "qty_increments" => "qty_increments", + "enable_qty_increments" => "enable_qty_increments", + "use_config_qty_increments" => "use_config_qty_increments" + ) + )->addAttributeToSelect( + array( + 'qty', + 'is_in_stock', + 'manage_stock', + 'use_config_manage_stock', + 'min_sale_qty', + 'qty_increments', + 'enable_qty_increments', + 'use_config_qty_increments' + ) + ); + + $this->joinPriceIndexLeft($collection, $websiteId); + $collection->getSelect()->group('e.entity_id'); - $customValues = ''; - if (isset($config['custom_name'])) { - $customValues .= $config['custom_name'] . ' '; - } + if (!empty($config['filters'])) { + $this->addFilters($config['filters'], $collection); + } - if (isset($config['custom_description'])) { - $customValues .= $config['custom_description'] . ' '; - } + return $collection; + } - if (isset($config['category_default'])) { - $customValues .= $config['category_default'] . ' '; + /** + * @param $collection + * @param $websiteId + */ + public function joinPriceIndexLeft($collection, $websiteId) + { + $resource = Mage::getResourceSingleton('core/resource'); + $tableName = array('price_index' => $resource->getTable('catalog/product_index_price')); + $joinCond = join(' AND ', array( + 'price_index.entity_id = e.entity_id', + 'price_index.website_id = ' . $websiteId, + 'price_index.customer_group_id = 0' + )); + $colls = array('final_price', 'min_price', 'max_price'); + $collection->getSelect()->joinLeft($tableName, $joinCond, $colls); + } + + /** + * @param $selectedAttrs + * + * @return array + */ + public function getAttributes($selectedAttrs) + { + $attributes = $this->getDefaultAttributes(); + foreach ($selectedAttrs as $selectedAtt) { + if (!empty($selectedAtt['source'])) { + $attributes[] = $selectedAtt['source']; } - preg_match_all("/{{([^}]*)}}/", $customValues, $foundAtts); - if (!empty($foundAtts)) { - foreach ($foundAtts[1] as $att) { - $attributes[] = $att; + if (!empty($selectedAtt['multi']) && is_array($selectedAtt['multi'])) { + foreach ($selectedAtt['multi'] as $attribute) { + $attributes[] = $attribute['source']; } } - $collection->addAttributeToSelect(array_unique($attributes)); - - if (!empty($config['filters'])) { - $this->addFilters($config['filters'], $collection); + if (!empty($selectedAtt['main'])) { + $attributes[] = $selectedAtt['main']; } + } - $collection->joinTable( - 'cataloginventory/stock_item', 'product_id=entity_id', array( - "qty" => "qty", - "is_in_stock" => "is_in_stock", - "manage_stock" => "manage_stock", - "use_config_manage_stock" => "use_config_manage_stock", - "min_sale_qty" => "min_sale_qty", - "qty_increments" => "qty_increments", - "enable_qty_increments" => "enable_qty_increments", - "use_config_qty_increments" => "use_config_qty_increments" - ) - )->addAttributeToSelect( - array( - 'qty', - 'is_in_stock', - 'manage_stock', - 'use_config_manage_stock', - 'min_sale_qty', - 'qty_increments', - 'enable_qty_increments', - 'use_config_qty_increments' - ) - ); - - $collection->getSelect()->group('e.entity_id'); + return array_unique($attributes); + } - $products = $collection->load(); - } else { - $products = $collection->getSize(); - } + /** + * Array of default Attributes + * + * @return array + */ + public function getDefaultAttributes() + { + $attributes = array(); + $attributes[] = 'url_key'; + $attributes[] = 'url_path'; + $attributes[] = 'sku'; + $attributes[] = 'price'; + $attributes[] = 'final_price'; + $attributes[] = 'price_model'; + $attributes[] = 'price_type'; + $attributes[] = 'special_price'; + $attributes[] = 'special_from_date'; + $attributes[] = 'special_to_date'; + $attributes[] = 'type_id'; + $attributes[] = 'tax_class_id'; + $attributes[] = 'tax_percent'; + $attributes[] = 'weight'; + $attributes[] = 'visibility'; + $attributes[] = 'type_id'; + $attributes[] = 'image'; + $attributes[] = 'small_image'; + $attributes[] = 'thumbnail'; + $attributes[] = 'status'; - return $products; + return $attributes; } /** - * @param $filters - * @param $collection + * @param $filters + * @param Mage_Catalog_Model_Resource_Product_Collection $collection + * @param $type + * + * @return Mage_Catalog_Model_Resource_Product_Collection */ - public function addFilters($filters, $collection) + public function addFilters($filters, $collection, $type = 'simple') { + $cType = array( + 'eq' => '=', + 'neq' => '!=', + 'gt' => '>', + 'gteq' => '>=', + 'lt' => '<', + 'lteg' => '<=' + ); + foreach ($filters as $filter) { $attribute = $filter['attribute']; - if ($filter['type'] == 'select') { - $attribute = $filter['attribute'] . '_value'; - } - $condition = $filter['condition']; $value = $filter['value']; + $productFilterType = $filter['product_type']; + $filterExpr = array(); + + if ($type == 'simple' && $productFilterType == 'parent') { + continue; + } + + if ($type == 'parent' && $productFilterType == 'simple') { + continue; + } + + $attributeModel = Mage::getSingleton('eav/config') + ->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attribute); + if (!$frontendInput = $attributeModel->getFrontendInput()) { + continue; + } + + if ($frontendInput == 'select' || $frontendInput == 'multiselect') { + $options = $attributeModel->getSource()->getAllOptions(); + if (strpos($value, ',') !== false) { + $values = array(); + $value = explode(',', $value); + foreach ($value as $v) { + $valueId = array_search(trim($v), array_column($options, 'label')); + if ($valueId) { + $values[] = $options[$valueId]['value']; + } + } + + $value = implode(',', $values); + } else { + $valueId = array_search($value, array_column($options, 'label')); + if ($valueId) { + $value = $options[$valueId]['value']; + } + } + } if ($attribute == 'final_price') { - $cType = array('eq' => '=', 'neq' => '!=', 'gt' => '>', 'gteq' => '>=', 'lt' => '<', 'lteg' => '<='); if (isset($cType[$condition])) { $collection->getSelect()->where('price_index.final_price ' . $cType[$condition] . ' ' . $value); } @@ -186,130 +258,142 @@ public function addFilters($filters, $collection) continue; } + if ($attribute == 'min_sale_qty') { + if (isset($cType[$condition])) { + $collection->getSelect()->where('cataloginventory_stock_item.min_sale_qty ' . $cType[$condition] . ' ' . $value); + } + + continue; + } + switch ($condition) { case 'nin': if (strpos($value, ',') !== false) { $value = explode(',', $value); } - $collection->addAttributeToFilter( - array( - array( - 'attribute' => $attribute, - $condition => $value - ), - array('attribute' => $attribute, 'null' => true) - ) - ); + $filterExpr[] = array('attribute' => $attribute, $condition => $value); + $filterExpr[] = array('attribute' => $attribute, 'null' => true); break; case 'in'; if (strpos($value, ',') !== false) { $value = explode(',', $value); } - $collection->addAttributeToFilter($attribute, array($condition => $value)); + $filterExpr[] = array('attribute' => $attribute, $condition => $value); break; case 'neq': - $collection->addAttributeToFilter( - array( - array('attribute' => $attribute, $condition => $value), - array('attribute' => $attribute, 'null' => true) - ) - ); + $filterExpr[] = array('attribute' => $attribute, $condition => $value); + $filterExpr[] = array('attribute' => $attribute, 'null' => true); break; case 'empty': - $collection->addAttributeToFilter($attribute, array('null' => true)); + $filterExpr[] = array('attribute' => $attribute, 'null' => true); break; case 'not-empty': - $collection->addAttributeToFilter($attribute, array('notnull' => true)); + $filterExpr[] = array('attribute' => $attribute, 'notnull' => true); + break; + case 'gt': + case 'gteq': + case 'lt': + case 'lteq': + if (is_numeric($value)) { + $filterExpr[] = array('attribute' => $attribute, $condition => $value); + } break; default: - $collection->addAttributeToFilter($attribute, array($condition => $value)); + $filterExpr[] = array('attribute' => $attribute, $condition => $value); break; } + + if (!empty($filterExpr)) { + if ($productFilterType == 'parent') { + $filterExpr[] = array('attribute' => 'type_id', 'eq' => 'simple'); + /** @noinspection PhpParamsInspection */ + $collection->addAttributeToFilter($filterExpr, '', 'left'); + } elseif ($productFilterType == 'simple') { + $filterExpr[] = array('attribute' => 'type_id', 'neq' => 'simple'); + /** @noinspection PhpParamsInspection */ + $collection->addAttributeToFilter($filterExpr, '', 'left'); + } else { + /** @noinspection PhpParamsInspection */ + $collection->addAttributeToFilter($filterExpr); + } + } } + + return $collection; } /** - * Araay of default Attributes + * @param $atts * * @return array */ - public function getDefaultAttributes() + public function getParentAttributeSelection($atts) { - $attributes = array(); - $attributes[] = 'url_key'; - $attributes[] = 'url_path'; - $attributes[] = 'sku'; - $attributes[] = 'price'; - $attributes[] = 'final_price'; - $attributes[] = 'price_model'; - $attributes[] = 'price_type'; - $attributes[] = 'special_price'; - $attributes[] = 'special_from_date'; - $attributes[] = 'special_to_date'; - $attributes[] = 'type_id'; - $attributes[] = 'tax_class_id'; - $attributes[] = 'tax_percent'; - $attributes[] = 'weight'; - $attributes[] = 'visibility'; - $attributes[] = 'type_id'; - $attributes[] = 'image'; - $attributes[] = 'small_image'; - $attributes[] = 'thumbnail'; - $attributes[] = 'status'; + $attributes = $this->getDefaultAttributes(); + foreach ($atts as $attribute) { + if (!empty($attribute['parent'])) { + if (!empty($attribute['source'])) { + if ($attribute['source'] != 'entity_id') { + $attributes[] = $attribute['source']; + } + } + } + } return $attributes; } - /** - * @param $products - * @param $config + * @param array $parentRelations + * @param array $config * - * @return array|bool + * @return Mage_Catalog_Model_Resource_Product_Collection */ - public function getParents($products, $config) + public function getParents($parentRelations, $config) { - if (!empty($config['conf_enabled'])) { - $ids = array(); - foreach ($products as $product) { - if ($parentId = Mage::helper('channable')->getParentData($product, $config)) { - $ids[] = $parentId; - } + if (!empty($config['conf_enabled']) && !empty($parentRelations)) { + if (!empty($config['bypass_flat'])) { + $collection = Mage::getModel('channable/resource_product_collection'); + } else { + $collection = Mage::getResourceModel('catalog/product_collection'); } - if (empty($ids)) { - return array(); - } - - $collection = Mage::getResourceModel('catalog/product_collection') - ->setStore($config['store_id']) + /** @var Mage_Catalog_Model_Resource_Product_Collection $collection */ + $collection->setStore($config['store_id']) ->addStoreFilter($config['store_id']) - ->addFinalPrice() ->addUrlRewrite() - ->addAttributeToFilter('entity_id', array('in', $ids)) - ->addAttributeToSelect(array_unique($config['parent_att'])); + ->addAttributeToFilter('entity_id', array('in' => array_values($parentRelations))) + ->addAttributeToSelect(array_unique($config['parent_att'])) + ->addAttributeToFilter('status', 1); if (!empty($config['hide_no_stock'])) { Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($collection); } + $this->joinPriceIndexLeft($collection, $config['website_id']); + $collection->getSelect()->group('e.entity_id'); + + if (!empty($config['filters'])) { + $collection = $this->addFilters($config['filters'], $collection, 'parent'); + } + return $collection->load(); } - - return false; } /** - * @param $atts + * Direct Database Query to get total records of collection with filters. * - * @return array + * @param Mage_Catalog_Model_Resource_Product_Collection $productCollection + * + * @return int */ - public function getParentAttributeSelection($atts) + public function getCollectionCountWithFilters($productCollection) { - $attributes = $this->getDefaultAttributes(); - $extraAttributes = explode(',', $atts); - - return array_merge($attributes, $extraAttributes); + $selectCountSql = $productCollection->getSelectCountSql(); + $connection = Mage::getSingleton('core/resource')->getConnection('core_read'); + $count = $connection->fetchOne($selectCountSql); + return $count; } } diff --git a/app/code/community/Magmodules/Channable/Model/Resource/Product/Collection.php b/app/code/community/Magmodules/Channable/Model/Resource/Product/Collection.php new file mode 100644 index 0000000..8232d13 --- /dev/null +++ b/app/code/community/Magmodules/Channable/Model/Resource/Product/Collection.php @@ -0,0 +1,42 @@ + + * @copyright Copyright (c) 2017 (http://www.magmodules.eu) + * @license https://www.magmodules.eu/terms.html Single Service License + */ + +class Magmodules_Channable_Model_Resource_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection +{ + + /** + * @return bool + */ + public function isEnabledFlat() + { + return false; + } + + /** + * Force Bypass Flat + * Initialize resources + */ + protected function _construct() + { + $this->_init('catalog/product'); + $this->_initTables(); + } + +} diff --git a/app/code/community/Magmodules/Channable/controllers/Adminhtml/ChannableController.php b/app/code/community/Magmodules/Channable/controllers/Adminhtml/ChannableController.php old mode 100755 new mode 100644 index 5286812..8008a2d --- a/app/code/community/Magmodules/Channable/controllers/Adminhtml/ChannableController.php +++ b/app/code/community/Magmodules/Channable/controllers/Adminhtml/ChannableController.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules helper = Mage::helper('channable'); + $this->model = Mage::getModel('channable/channable'); + $this->session = Mage::getSingleton('adminhtml/session'); + } + /** * addToFlat contoller action */ public function addToFlatAction() { - $attributes = Mage::getModel("channable/channable")->getFeedAttributes(); - $nonFlatAttributes = Mage::helper('channable')->checkFlatCatalog($attributes); + $attributes = $this->model->getFeedAttributes(); + $nonFlatAttributes = $this->helper->checkFlatCatalog($attributes); - foreach ($nonFlatAttributes as $key => $value) { - Mage::getModel('catalog/resource_eav_attribute')->load($key) - ->setUsedInProductListing(1) - ->save(); + try { + foreach ($nonFlatAttributes as $key => $value) { + Mage::getModel('catalog/resource_eav_attribute')->load($key) + ->setUsedInProductListing(1) + ->save(); + } + $msg = $this->helper->__('Attributes added to Flat Catalog, please reindex Product Flat Data.'); + $this->session->addSuccess($msg); + } catch (\Exception $e) { + $this->session->addError($e->getMessage()); } - $msg = Mage::helper('channable')->__('Attributes added to Flat Catalog, please reindex Product Flat Data.'); - Mage::getSingleton('adminhtml/session')->addSuccess($msg); - $this->_redirect('adminhtml/system_config/edit/section/channable'); } @@ -47,28 +72,34 @@ public function addToFlatAction() */ public function createTokenAction() { - $oldToken = Mage::getModel('core/config_data')->getCollection() - ->addFieldToFilter('path', 'channable/connect/token') - ->addFieldToFilter('scope_id', 0) - ->addFieldToFilter('scope', 'default') - ->getFirstItem() - ->getValue(); + try { + $oldToken = Mage::getModel('core/config_data')->getCollection() + ->addFieldToFilter('path', 'channable/connect/token') + ->addFieldToFilter('scope_id', 0) + ->addFieldToFilter('scope', 'default') + ->getFirstItem() + ->getValue(); - $token = ''; - $chars = str_split("abcdefghijklmnopqrstuvwxyz0123456789"); - for ($i = 0; $i < 32; $i++) { - $token .= $chars[array_rand($chars)]; - } + $token = ''; + $chars = str_split("abcdefghijklmnopqrstuvwxyz0123456789"); + for ($i = 0; $i < 32; $i++) { + $token .= $chars[array_rand($chars)]; + } + + Mage::getModel('core/config') + ->saveConfig('channable/connect/token', Mage::helper('core')->encrypt($token)); - Mage::getModel('core/config')->saveConfig('channable/connect/token', Mage::helper('core')->encrypt($token)); + if (!empty($oldToken)) { + $msg = 'New Token created, please update Channable Dashboard with this new token'; + } else { + $msg = 'New Token created, please link your account using the auto update'; + } - if (!empty($oldToken)) { - $msg = 'New Token created, please update Channable Dashboard with this new token'; - } else { - $msg = 'New Token created, please link your account using the auto update'; + $this->session->addSuccess(Mage::helper('channable')->__($msg)); + } catch (\Exception $e) { + $this->session->addError($e->getMessage()); } - Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('channable')->__($msg)); $this->_redirect('adminhtml/system_config/edit/section/channable'); } diff --git a/app/code/community/Magmodules/Channable/controllers/Adminhtml/SelftestController.php b/app/code/community/Magmodules/Channable/controllers/Adminhtml/SelftestController.php new file mode 100644 index 0000000..06a46c5 --- /dev/null +++ b/app/code/community/Magmodules/Channable/controllers/Adminhtml/SelftestController.php @@ -0,0 +1,55 @@ + + * @copyright Copyright (c) 2018 (http://www.magmodules.eu) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ + +class Magmodules_Channable_Adminhtml_SelftestController extends Mage_Adminhtml_Controller_Action +{ + + /** + * @var Magmodules_Channable_Helper_Selftest + */ + public $helper; + + /** + * Construct. + */ + public function _construct() + { + $this->helper = Mage::helper('channable/selftest'); + parent::_construct(); + } + + /** + * + */ + public function runAction() + { + $results = $this->helper->runTests(); + $msg = implode('
', $results); + Mage::app()->getResponse()->setBody($msg); + } + + /** + * @return mixed + */ + protected function _isAllowed() + { + return Mage::getSingleton('admin/session')->isAllowed('admin/channable/channable'); + } +} \ No newline at end of file diff --git a/app/code/community/Magmodules/Channable/controllers/FeedController.php b/app/code/community/Magmodules/Channable/controllers/FeedController.php old mode 100755 new mode 100644 index c413ff7..36354de --- a/app/code/community/Magmodules/Channable/controllers/FeedController.php +++ b/app/code/community/Magmodules/Channable/controllers/FeedController.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules helper = Mage::helper('channable'); + $this->model = Mage::getModel('channable/channable'); + } + /** * */ public function getAction() { $storeId = $this->getRequest()->getParam('store'); - if (Mage::getStoreConfig('channable/connect/enabled', $storeId)) { + $enabled = Mage::getStoreConfig('channable/connect/enabled', $storeId); + + if ($enabled) { $code = $this->getRequest()->getParam('code'); - $page = $this->getRequest()->getParam('page'); + $page = $this->getRequest()->getParam('page', 1); if ($storeId && $code) { - if ($code == Mage::helper('channable')->getToken()) { + if ($code == $this->helper->getToken()) { $timeStart = microtime(true); - $limit = Mage::getStoreConfig('channable/connect/max_products', $storeId); + /** @var Mage_Core_Model_App_Emulation $appEmulation */ $appEmulation = Mage::getSingleton('core/app_emulation'); $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId); Mage::app()->loadAreaPart( Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS )->loadArea(Mage_Core_Model_App_Area::AREA_FRONTEND); - if ($feed = Mage::getModel('channable/channable')->generateFeed( - $storeId, $limit, $timeStart, - $page - ) - ) { + if ($feed = $this->model->generateFeed($storeId, $timeStart, $page)) { if ($this->getRequest()->getParam('array')) { $this->getResponse()->setBody(Zend_Debug::dump($feed, null, false)); } else { diff --git a/app/code/community/Magmodules/Channable/data/magmodules_channable_setup/data-upgrade-1.4.8-1.4.9.php b/app/code/community/Magmodules/Channable/data/magmodules_channable_setup/data-upgrade-1.4.8-1.4.9.php index 437a47c..d1e8959 100644 --- a/app/code/community/Magmodules/Channable/data/magmodules_channable_setup/data-upgrade-1.4.8-1.4.9.php +++ b/app/code/community/Magmodules/Channable/data/magmodules_channable_setup/data-upgrade-1.4.8-1.4.9.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules - - diff --git a/app/code/community/Magmodules/Channable/etc/config.xml b/app/code/community/Magmodules/Channable/etc/config.xml old mode 100755 new mode 100644 index e38abb4..874d494 --- a/app/code/community/Magmodules/Channable/etc/config.xml +++ b/app/code/community/Magmodules/Channable/etc/config.xml @@ -14,14 +14,14 @@ ~ @category Magmodules ~ @package Magmodules_Channable ~ @author Magmodules - 1.5.5 + 1.6.0 @@ -90,6 +90,13 @@ + + + + magmodules_channable.xml + + + diff --git a/app/code/community/Magmodules/Channable/etc/system.xml b/app/code/community/Magmodules/Channable/etc/system.xml old mode 100755 new mode 100644 index ddf4ed1..5cb1bb3 --- a/app/code/community/Magmodules/Channable/etc/system.xml +++ b/app/code/community/Magmodules/Channable/etc/system.xml @@ -14,7 +14,7 @@ ~ @category Magmodules ~ @package Magmodules_Channable ~ @author Magmodules @@ -506,7 +506,7 @@ - + text 5 1 @@ -515,7 +515,7 @@ 1 - + channable/adminhtml_system_config_form_field_note 1 1 @@ -523,7 +523,7 @@ 1 - + channable/adminhtml_system_config_form_field_heading 30 1 @@ -531,7 +531,7 @@ 1 - + channable/adminhtml_config_form_field_extra channable/adminhtml_system_config_backend_design_extra 32 @@ -624,6 +624,7 @@ 1 +
Note for Include:

Simple products within a bundled, configurable or grouped product are treated as own entities, so these should also be present in the included categories.

Note for Exclude:
Exclude the products from these categories. Products that are available within different categories need to be excluded from all of the categories they are assigned to.]]>
@@ -663,7 +664,7 @@
- + text 7 1 @@ -671,11 +672,19 @@ 1 1 + + + channable/adminhtml_system_config_form_field_heading + 1 + 1 + 1 + 1 + select adminhtml/system_config_source_yesno - 21 + 2 1 0 0 @@ -684,7 +693,7 @@ text - 22 + 3 1 0 0 @@ -696,7 +705,7 @@ text - 23 + 4 1 0 0 @@ -705,12 +714,56 @@ + + + channable/adminhtml_system_config_form_field_heading + 10 + 1 + 0 + 0 + + + + select + adminhtml/system_config_source_yesno + 11 + 1 + 0 + 0 + + + + + channable/adminhtml_system_config_form_field_heading + 50 + 1 + 0 + 0 + + + + button + channable/adminhtml_system_config_form_field_button + 51 + 1 + 1 + 1 + + + + button + channable/adminhtml_system_config_form_field_result + 52 + 1 + 1 + 1 + text - 8 + 9 1 1 1 diff --git a/app/code/community/Magmodules/Channable/sql/magmodules_channable_setup/upgrade-1.4.8-1.4.9.php b/app/code/community/Magmodules/Channable/sql/magmodules_channable_setup/upgrade-1.4.8-1.4.9.php old mode 100755 new mode 100644 index e2f0709..2242e2f --- a/app/code/community/Magmodules/Channable/sql/magmodules_channable_setup/upgrade-1.4.8-1.4.9.php +++ b/app/code/community/Magmodules/Channable/sql/magmodules_channable_setup/upgrade-1.4.8-1.4.9.php @@ -14,7 +14,7 @@ * @category Magmodules * @package Magmodules_Channable * @author Magmodules + + + + + + magmodules/channable/style.css + + + + diff --git a/app/design/adminhtml/default/default/template/magmodules/channable/system/config/test_button.phtml b/app/design/adminhtml/default/default/template/magmodules/channable/system/config/test_button.phtml new file mode 100644 index 0000000..e20a6e7 --- /dev/null +++ b/app/design/adminhtml/default/default/template/magmodules/channable/system/config/test_button.phtml @@ -0,0 +1,43 @@ + + * @copyright Copyright (c) 2018 (http://www.magmodules.eu) + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) + */ +?> + +getButtonHtml() ?> \ No newline at end of file diff --git a/app/etc/modules/Magmodules_Channable.xml b/app/etc/modules/Magmodules_Channable.xml index fa35668..7b92576 100755 --- a/app/etc/modules/Magmodules_Channable.xml +++ b/app/etc/modules/Magmodules_Channable.xml @@ -14,7 +14,7 @@ ~ @category Magmodules ~ @package Magmodules_Channable ~ @author Magmodules diff --git a/composer.json b/composer.json index c639b3a..0504f92 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "name": "magmodules/magento1-channable", "type": "magento-module", "description": "Magento 1 Channable integration", + "version": "v1.6.0", "keywords": [ "magento" ], diff --git a/modman b/modman index 36d5d09..061146d 100755 --- a/modman +++ b/modman @@ -1,12 +1,21 @@ +# Modman file generated by 'generate-modman' +# app/code app/code/community/Magmodules/Channable app/code/community/Magmodules/Channable +# app/etc app/etc/modules/Magmodules_Channable.xml app/etc/modules/Magmodules_Channable.xml -app/locale/da_DK/Magmodules_Channable.csv app/locale/da_DK/Magmodules_Channable.csv -app/locale/de_DE/Magmodules_Channable.csv app/locale/de_DE/Magmodules_Channable.csv +# app/locale app/locale/en_US/Magmodules_Channable.csv app/locale/en_US/Magmodules_Channable.csv -app/locale/es_ES/Magmodules_Channable.csv app/locale/es_ES/Magmodules_Channable.csv -app/locale/fr_FR/Magmodules_Channable.csv app/locale/fr_FR/Magmodules_Channable.csv +app/locale/sv_SE/Magmodules_Channable.csv app/locale/sv_SE/Magmodules_Channable.csv app/locale/it_IT/Magmodules_Channable.csv app/locale/it_IT/Magmodules_Channable.csv +app/locale/pt_PT/Magmodules_Channable.csv app/locale/pt_PT/Magmodules_Channable.csv app/locale/nl_NL/Magmodules_Channable.csv app/locale/nl_NL/Magmodules_Channable.csv +app/locale/es_ES/Magmodules_Channable.csv app/locale/es_ES/Magmodules_Channable.csv +app/locale/da_DK/Magmodules_Channable.csv app/locale/da_DK/Magmodules_Channable.csv app/locale/pl_PL/Magmodules_Channable.csv app/locale/pl_PL/Magmodules_Channable.csv -app/locale/pt_PT/Magmodules_Channable.csv app/locale/pt_PT/Magmodules_Channable.csv -app/locale/sv_SE/Magmodules_Channable.csv app/locale/sv_SE/Magmodules_Channable.csv \ No newline at end of file +app/locale/fr_FR/Magmodules_Channable.csv app/locale/fr_FR/Magmodules_Channable.csv +app/locale/de_DE/Magmodules_Channable.csv app/locale/de_DE/Magmodules_Channable.csv +# app/design +app/design/adminhtml/default/default/layout/magmodules_channable.xml app/design/adminhtml/default/default/layout/magmodules_channable.xml +app/design/adminhtml/default/default/template/magmodules/channable/system/config/test_button.phtml app/design/adminhtml/default/default/template/magmodules/channable/system/config/test_button.phtml +# skin +skin/adminhtml/default/default/magmodules/channable/style.css skin/adminhtml/default/default/magmodules/channable/style.css diff --git a/skin/adminhtml/default/default/magmodules/channable/style.css b/skin/adminhtml/default/default/magmodules/channable/style.css new file mode 100644 index 0000000..c48ac6d --- /dev/null +++ b/skin/adminhtml/default/default/magmodules/channable/style.css @@ -0,0 +1,69 @@ +.channable-success { + display: block; + border: 2px solid #79A22E; + background-color: white; + padding: 7px; + width: 95%; +} + +.channable-success:before { + font-size: 12px; + font-style: normal; + font-weight: 400; + padding: 10px; + color: #79A22E; + content: '\2713'; +} + +.channable-success .more { + float: right; + margin-right: 10px; +} + +.channable-error { + display: block; + background-color: white; + border: 2px solid #EB5202; + padding: 7px; + width: 95%; +} + +.channable-error i { + display:block; +} + +.channable-error:before { + color: #EB5202; + font-size: 15px; + font-style: normal; + font-weight: 400; + padding: 10px; + content: '\00D7'; +} + +.channable-error .more { + float: right; + margin-right: 10px; +} + +.channable-notice { + display: block; + border: 2px solid #6f8892; + background-color: white; + padding: 7px; + width: 95%; +} + +.channable-notice:before { + font-size: 15px; + font-style: normal; + font-weight: 400; + padding: 10px; + color: #6f8892; + content: '\0021' +} + +.channable-notice .more { + float: right; + margin-right: 10px; +} \ No newline at end of file