linccce

Hope this clear things up.

Feb 13th, 2015
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.33 KB | None | 0 0
  1. Module is appearing in System -> Configuration -> Advanced (under Advanced Group) and is enabled
  2.  
  3. Cache was deleted with rm -r var/cache
  4. Session was deleted with rm -r var/session
  5.  stat -c "%a %n" app/code/local/Proweb/CustomClass/*
  6. 755 app/code/local/Proweb/CustomClass/Block
  7. 755 app/code/local/Proweb/CustomClass/Model
  8. 755 app/code/local/Proweb/CustomClass/etc
  9. 755 app/code/local/Proweb/CustomClass/sql
  10.  
  11.  
  12. app/etc/modules/Proweb_CustomClass.xml:
  13. <?xml version="1.0"?>
  14. <config>
  15.     <modules>
  16.         <Proweb_CustomClass>
  17.             <active>true</active>
  18.             <codePool>local</codePool>
  19.         </Proweb_CustomClass>
  20.     </modules>
  21. </config>
  22.  
  23. app/code/local/Proweb/CustomClass/etc/Config.xml
  24.  
  25. <?xml version="1.0"?>
  26. <config>
  27.     <modules>
  28.         <Proweb_CustomClass>
  29.             <version>1.0</version>
  30.         </Proweb_CustomClass>
  31.     </modules>
  32.     <global>
  33.         <blocks>
  34.             <Adminhtml>
  35.                 <rewrite>
  36.                     <Catalog_Product_Edit_Tab_Options_Option>
  37.                         Proweb_CustomClass_Block_Adminhtml_Option
  38.                     </Catalog_Product_Edit_Tab_Options_Option>
  39.                 </rewrite>
  40.             </Adminhtml>
  41.         </blocks>
  42.         <resources>
  43.             <customclass_setup>
  44.                 <setup>
  45.                     <module>Proweb_CustomClass</module>
  46.                     <class>Proweb_CustomClass_Model_Resource_Setup</class>
  47.                 </setup>
  48.             </customclass_setup>
  49.         </resources>
  50.     </global>
  51. </config>
  52.  
  53. app/code/local/Proweb/CustomClass/Block/Adminhtml/Options.php
  54.  
  55. <?php
  56.     class Proweb_CustomCss_Block_Adminhtml_Option extends Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Options_Option {
  57.  
  58.         public function getOptionValues()
  59.         {
  60.             $optionsArr = array_reverse($this->getProduct()->getOptions(), true);
  61.  
  62.             var_dump($optionsArr); exit;
  63. //        $optionsArr = $this->getProduct()->getOptions();
  64.  
  65.             if (!$this->_values) {
  66.                 $showPrice = $this->getCanReadPrice();
  67.                 $values = array();
  68.                 $scope = (int) Mage::app()->getStore()->getConfig(Mage_Core_Model_Store::XML_PATH_PRICE_SCOPE);
  69.                 foreach ($optionsArr as $option) {
  70.                     /* @var $option Mage_Catalog_Model_Product_Option */
  71.  
  72.                     $this->setItemCount($option->getOptionId());
  73.  
  74.                     $value = array();
  75.  
  76.                     $value['id'] = $option->getOptionId();
  77.                     $value['item_count'] = $this->getItemCount();
  78.                     $value['option_id'] = $option->getOptionId();
  79.                     $value['title'] = $this->escapeHtml($option->getTitle());
  80.                     $value['type'] = $option->getType();
  81.                     $value['is_require'] = $option->getIsRequire();
  82.                     $value['sort_order'] = $option->getSortOrder();
  83.                     $value['custom_class'] = $option->getCustomClass();
  84.                     $value['can_edit_price'] = $this->getCanEditPrice();
  85.  
  86.                     if ($this->getProduct()->getStoreId() != '0') {
  87.                         $value['checkboxScopeTitle'] = $this->getCheckboxScopeHtml($option->getOptionId(), 'title',
  88.                             is_null($option->getStoreTitle()));
  89.                         $value['scopeTitleDisabled'] = is_null($option->getStoreTitle())?'disabled':null;
  90.                     }
  91.  
  92.                     if ($option->getGroupByType() == Mage_Catalog_Model_Product_Option::OPTION_GROUP_SELECT) {
  93.  
  94. //                    $valuesArr = array_reverse($option->getValues(), true);
  95.  
  96.                         $i = 0;
  97.                         $itemCount = 0;
  98.                         foreach ($option->getValues() as $_value) {
  99.                             /* @var $_value Mage_Catalog_Model_Product_Option_Value */
  100.                             $value['optionValues'][$i] = array(
  101.                                 'item_count' => max($itemCount, $_value->getOptionTypeId()),
  102.                                 'option_id' => $_value->getOptionId(),
  103.                                 'option_type_id' => $_value->getOptionTypeId(),
  104.                                 'title' => $this->escapeHtml($_value->getTitle()),
  105.                                 'price' => ($showPrice)
  106.                                     ? $this->getPriceValue($_value->getPrice(), $_value->getPriceType()) : '',
  107.                                 'price_type' => ($showPrice) ? $_value->getPriceType() : 0,
  108.                                 'sku' => $this->escapeHtml($_value->getSku()),
  109.                                 'sort_order' => $_value->getSortOrder(),
  110.                                 'custom_class' => $this->escapeHtml($_value->getCustomClass())
  111.                             );
  112.  
  113.                             if ($this->getProduct()->getStoreId() != '0') {
  114.                                 $value['optionValues'][$i]['checkboxScopeTitle'] = $this->getCheckboxScopeHtml(
  115.                                     $_value->getOptionId(), 'title', is_null($_value->getStoreTitle()),
  116.                                     $_value->getOptionTypeId());
  117.                                 $value['optionValues'][$i]['scopeTitleDisabled'] = is_null($_value->getStoreTitle())
  118.                                     ? 'disabled' : null;
  119.                                 if ($scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) {
  120.                                     $value['optionValues'][$i]['checkboxScopePrice'] = $this->getCheckboxScopeHtml(
  121.                                         $_value->getOptionId(), 'price', is_null($_value->getstorePrice()),
  122.                                         $_value->getOptionTypeId());
  123.                                     $value['optionValues'][$i]['scopePriceDisabled'] = is_null($_value->getStorePrice())
  124.                                         ? 'disabled' : null;
  125.                                 }
  126.                             }
  127.                             $i++;
  128.                         }
  129.                     } else {
  130.                         $value['price'] = ($showPrice)
  131.                             ? $this->getPriceValue($option->getPrice(), $option->getPriceType()) : '';
  132.                         $value['price_type'] = $option->getPriceType();
  133.                         $value['sku'] = $this->escapeHtml($option->getSku());
  134.                         $value['custom_class'] = $option->getCustomClass();
  135.                         $value['max_characters'] = $option->getMaxCharacters();
  136.                         $value['file_extension'] = $option->getFileExtension();
  137.                         $value['image_size_x'] = $option->getImageSizeX();
  138.                         $value['image_size_y'] = $option->getImageSizeY();
  139.                         if ($this->getProduct()->getStoreId() != '0' &&
  140.                             $scope == Mage_Core_Model_Store::PRICE_SCOPE_WEBSITE) {
  141.                             $value['checkboxScopePrice'] = $this->getCheckboxScopeHtml($option->getOptionId(),
  142.                                 'price', is_null($option->getStorePrice()));
  143.                             $value['scopePriceDisabled'] = is_null($option->getStorePrice())?'disabled':null;
  144.                         }
  145.                     }
  146.                     $values[] = new Varien_Object($value);
  147.                 }
  148.                 $this->_values = $values;
  149.             }
  150.  
  151.             return $this->_values;
  152.         }
  153.  
  154.         public function getCustomCss() {
  155.                 var_dump($_POST);
  156.         }
  157.     }
  158.  
  159.  
  160. app/code/local/Proweb/CustomClass/Model/Resource/Setup.php
  161. <?php
  162.  
  163.     class Proweb_CustomClass_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
  164.  
  165.     }
  166.  
  167. app/code/local/Proweb/CustomClass/sql/customclass_setup/mysql4-install-0.1.0.php
  168.  
  169. <?php
  170.     $installer = $this;
  171.     $installer->startSetup();
  172.     $installer->run("ALTER TABLE `catalog_product_option` ADD `custom_class` text");
  173.     $installer->endSetup();
Advertisement
Add Comment
Please, Sign In to add comment