Version Notes
This extension has been tested and marked as (Stable).
Download this release
Release Info
| Developer | Christopher Silvey |
| Extension | Beckin_WeightAttribute |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/Beckin/WeightAttribute/Block/Catalog/Product/View/Attributes.php +47 -0
- app/code/community/Beckin/WeightAttribute/Block/Donation.php +36 -0
- app/code/community/Beckin/WeightAttribute/Helper/Data.php +6 -0
- app/code/community/Beckin/WeightAttribute/etc/adminhtml.xml +49 -0
- app/code/community/Beckin/WeightAttribute/etc/config.xml +47 -0
- app/code/community/Beckin/WeightAttribute/etc/system.xml +89 -0
- app/etc/modules/Beckin_WeightAttribute.xml +14 -0
- package.xml +28 -0
app/code/community/Beckin/WeightAttribute/Block/Catalog/Product/View/Attributes.php
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Beckin_WeightAttribute_Block_Catalog_Product_View_Attributes extends Mage_Catalog_Block_Product_View_Attributes
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
public function getAdditionalData(array $excludeAttr = array())
|
| 7 |
+
{
|
| 8 |
+
$data = array();
|
| 9 |
+
$product = $this->getProduct();
|
| 10 |
+
$attributes = $product->getAttributes();
|
| 11 |
+
foreach ($attributes as $attribute) {
|
| 12 |
+
|
| 13 |
+
if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
|
| 14 |
+
$value = $attribute->getFrontend()->getValue($product);
|
| 15 |
+
|
| 16 |
+
if (!$product->hasData($attribute->getAttributeCode())) {
|
| 17 |
+
$value = Mage::helper('catalog')->__('N/A');
|
| 18 |
+
} elseif ((string)$value == '') {
|
| 19 |
+
$value = Mage::helper('catalog')->__('No');
|
| 20 |
+
} elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
|
| 21 |
+
$value = Mage::app()->getStore()->convertPrice($value, true);
|
| 22 |
+
}
|
| 23 |
+
elseif (Mage::getStoreConfig('weightattribute/settings/enable'))
|
| 24 |
+
{
|
| 25 |
+
if ($attribute->getFrontendInput() == 'weight' && is_string($value)) {
|
| 26 |
+
$_weight = $this->htmlEscape($product->getWeight());
|
| 27 |
+
if ($_weight < 1) {
|
| 28 |
+
$value = number_format($_weight*1000,2) . " Grams";
|
| 29 |
+
} else {
|
| 30 |
+
$value = number_format($_weight,2) . " Lbs";
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
if (is_string($value) && strlen($value)) {
|
| 36 |
+
$data[$attribute->getAttributeCode()] = array(
|
| 37 |
+
'label' => $attribute->getStoreLabel(),
|
| 38 |
+
'value' => $value,
|
| 39 |
+
'code' => $attribute->getAttributeCode()
|
| 40 |
+
);
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
return $data;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
}
|
app/code/community/Beckin/WeightAttribute/Block/Donation.php
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Beckin_WeightAttribute_Block_Donation extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
|
| 4 |
+
|
| 5 |
+
public function render(Varien_Data_Form_Element_Abstract $element) {
|
| 6 |
+
$content = '<p></p>';
|
| 7 |
+
$content.= '<style>
|
| 8 |
+
.donation {
|
| 9 |
+
margin-bottom: 10px;
|
| 10 |
+
padding: 10px;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
.donation h3 {
|
| 14 |
+
color: #444;
|
| 15 |
+
padding: 0 0 10px 0;
|
| 16 |
+
font-size: 13px;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
</style>
|
| 20 |
+
|
| 21 |
+
<div class="donation">
|
| 22 |
+
<h3>Help support our free extensions and hard work by making a donation of any amount. Thank You!</h3>
|
| 23 |
+
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=BVDZJJ8UYEQUN"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" alt="Donate Button" /></a>
|
| 24 |
+
|
| 25 |
+
</div>'
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
;
|
| 29 |
+
|
| 30 |
+
return $content;
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
}
|
app/code/community/Beckin/WeightAttribute/Helper/Data.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Beckin_WeightAttribute_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
}
|
app/code/community/Beckin/WeightAttribute/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Beckin_DropDownShipping extension
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
*
|
| 13 |
+
* @category Beckin
|
| 14 |
+
* @package Beckin_WeightAttribute
|
| 15 |
+
* @copyright Copyright (c) 2012 Beckin Designs
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
/**
|
| 19 |
+
* @category Beckin
|
| 20 |
+
* @package Beckin_WeightAttribute
|
| 21 |
+
* @author Christopher Silvey <webmaster@beckin.com> http://www.beckin.com
|
| 22 |
+
*/
|
| 23 |
+
-->
|
| 24 |
+
<config>
|
| 25 |
+
|
| 26 |
+
<acl>
|
| 27 |
+
<resources>
|
| 28 |
+
<all>
|
| 29 |
+
<title>Allow Everything</title>
|
| 30 |
+
</all>
|
| 31 |
+
<admin>
|
| 32 |
+
<children>
|
| 33 |
+
<system>
|
| 34 |
+
<children>
|
| 35 |
+
<config>
|
| 36 |
+
<children>
|
| 37 |
+
<weightattribute>
|
| 38 |
+
<title>Beckin Weight Attribute Extension</title>
|
| 39 |
+
</weightattribute>
|
| 40 |
+
</children>
|
| 41 |
+
</config>
|
| 42 |
+
</children>
|
| 43 |
+
</system>
|
| 44 |
+
</children>
|
| 45 |
+
</admin>
|
| 46 |
+
</resources>
|
| 47 |
+
</acl>
|
| 48 |
+
|
| 49 |
+
</config>
|
app/code/community/Beckin/WeightAttribute/etc/config.xml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Beckin_DropDownShipping extension
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
*
|
| 13 |
+
* @category Beckin
|
| 14 |
+
* @package Beckin_WeightAttribute
|
| 15 |
+
* @copyright Copyright (c) 2012 Beckin Designs
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
/**
|
| 19 |
+
* @category Beckin
|
| 20 |
+
* @package Beckin_WeightAttribute
|
| 21 |
+
* @author Christopher Silvey <webmaster@beckin.com> http://www.beckin.com
|
| 22 |
+
*/
|
| 23 |
+
-->
|
| 24 |
+
<config>
|
| 25 |
+
<modules>
|
| 26 |
+
<Beckin_WeightAttribute><version>1.0.0</version></Beckin_WeightAttribute>
|
| 27 |
+
</modules>
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
<global>
|
| 31 |
+
<blocks>
|
| 32 |
+
<weightattribute>
|
| 33 |
+
<class>Beckin_WeightAttribute_Block</class>
|
| 34 |
+
</weightattribute>
|
| 35 |
+
<catalog>
|
| 36 |
+
<rewrite>
|
| 37 |
+
<product_view_attributes>Beckin_WeightAttribute_Block_Catalog_Product_View_Attributes</product_view_attributes>
|
| 38 |
+
</rewrite>
|
| 39 |
+
</catalog>
|
| 40 |
+
</blocks>
|
| 41 |
+
<helpers>
|
| 42 |
+
<weightattribute>
|
| 43 |
+
<class>Beckin_WeightAttribute_Helper</class>
|
| 44 |
+
</weightattribute>
|
| 45 |
+
</helpers>
|
| 46 |
+
</global>
|
| 47 |
+
</config>
|
app/code/community/Beckin/WeightAttribute/etc/system.xml
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* Beckin_DropDownShipping extension
|
| 5 |
+
*
|
| 6 |
+
* NOTICE OF LICENSE
|
| 7 |
+
*
|
| 8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
| 9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
| 10 |
+
* It is also available through the world-wide-web at this URL:
|
| 11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
| 12 |
+
*
|
| 13 |
+
* @category Beckin
|
| 14 |
+
* @package Beckin_WeightAttribute
|
| 15 |
+
* @copyright Copyright (c) 2012 Beckin Designs
|
| 16 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
| 17 |
+
*/
|
| 18 |
+
/**
|
| 19 |
+
* @category Beckin
|
| 20 |
+
* @package Beckin_WeightAttribute
|
| 21 |
+
* @author Christopher Silvey <webmaster@beckin.com> http://www.beckin.com
|
| 22 |
+
*/
|
| 23 |
+
-->
|
| 24 |
+
<config>
|
| 25 |
+
<tabs>
|
| 26 |
+
<beckin translate="label">
|
| 27 |
+
<label>Beckin Extensions</label>
|
| 28 |
+
<sort_order>100</sort_order>
|
| 29 |
+
</beckin>
|
| 30 |
+
</tabs>
|
| 31 |
+
|
| 32 |
+
<sections>
|
| 33 |
+
<weightattribute translate="label">
|
| 34 |
+
<label>Weight Attribute</label>
|
| 35 |
+
<tab>beckin</tab>
|
| 36 |
+
<frontend_type>text</frontend_type>
|
| 37 |
+
<sort_order>1010</sort_order>
|
| 38 |
+
<show_in_default>1</show_in_default>
|
| 39 |
+
<show_in_website>1</show_in_website>
|
| 40 |
+
<show_in_store>1</show_in_store>
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
<groups>
|
| 44 |
+
<settings translate="label">
|
| 45 |
+
<label>Settings</label>
|
| 46 |
+
<frontend_type>text</frontend_type>
|
| 47 |
+
<sort_order>1</sort_order>
|
| 48 |
+
<show_in_default>1</show_in_default>
|
| 49 |
+
<show_in_website>1</show_in_website>
|
| 50 |
+
<show_in_store>1</show_in_store>
|
| 51 |
+
|
| 52 |
+
<fields>
|
| 53 |
+
<enable translate="label">
|
| 54 |
+
<label>Enable</label>
|
| 55 |
+
<comment>
|
| 56 |
+
<![CDATA[Enable or Disable this extension.]]>
|
| 57 |
+
</comment>
|
| 58 |
+
<frontend_type>select</frontend_type>
|
| 59 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 60 |
+
<sort_order>1</sort_order>
|
| 61 |
+
<show_in_default>1</show_in_default>
|
| 62 |
+
<show_in_website>1</show_in_website>
|
| 63 |
+
<show_in_store>1</show_in_store>
|
| 64 |
+
</enable>
|
| 65 |
+
</fields>
|
| 66 |
+
|
| 67 |
+
</settings>
|
| 68 |
+
<donate translate="label">
|
| 69 |
+
<label>Like our free extensions?</label>
|
| 70 |
+
<frontend_type>text</frontend_type>
|
| 71 |
+
<sort_order>20</sort_order>
|
| 72 |
+
<show_in_default>1</show_in_default>
|
| 73 |
+
<show_in_website>1</show_in_website>
|
| 74 |
+
<show_in_store>1</show_in_store>
|
| 75 |
+
|
| 76 |
+
<fields>
|
| 77 |
+
<donation>
|
| 78 |
+
<frontend_model>weightattribute/donation</frontend_model>
|
| 79 |
+
<sort_order>10</sort_order>
|
| 80 |
+
<show_in_default>1</show_in_default>
|
| 81 |
+
<show_in_website>1</show_in_website>
|
| 82 |
+
<show_in_store>1</show_in_store>
|
| 83 |
+
</donation>
|
| 84 |
+
</fields>
|
| 85 |
+
</donate>
|
| 86 |
+
</groups>
|
| 87 |
+
</weightattribute>
|
| 88 |
+
</sections>
|
| 89 |
+
</config>
|
app/etc/modules/Beckin_WeightAttribute.xml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Beckin_WeightAttribute>
|
| 5 |
+
|
| 6 |
+
<!-- Whether our module is active: true or false -->
|
| 7 |
+
<active>true</active>
|
| 8 |
+
|
| 9 |
+
<!-- Which code pool to use: core, community or local -->
|
| 10 |
+
<codePool>community</codePool>
|
| 11 |
+
|
| 12 |
+
</Beckin_WeightAttribute>
|
| 13 |
+
</modules>
|
| 14 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Beckin_WeightAttribute</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Are you tired of those extra weight attribute zeros displaying on the product page? Wish there was a way to remove them? Now you can with this free extension.</summary>
|
| 10 |
+
<description>This Weight Attribute Extension easily strips those unwanted zeros from the product additional information tab located on the product page. 
|
| 11 |
+

|
| 12 |
+
This extension formats both Grams and Pounds. 
|
| 13 |
+

|
| 14 |
+
See the following for an example.
|
| 15 |
+

|
| 16 |
+
Instead of displaying:
|
| 17 |
+
Weight 1.2500
|
| 18 |
+

|
| 19 |
+
This extension will change this to:
|
| 20 |
+
Weight 1.25 lbs</description>
|
| 21 |
+
<notes>This extension has been tested and marked as (Stable).</notes>
|
| 22 |
+
<authors><author><name>Christopher Silvey</name><user>tech0925</user><email>dsilvey@rocketmail.com</email></author></authors>
|
| 23 |
+
<date>2012-12-21</date>
|
| 24 |
+
<time>20:00:11</time>
|
| 25 |
+
<contents><target name="magecommunity"><dir name="Beckin"><dir name="WeightAttribute"><dir name="Block"><dir name="Catalog"><dir name="Product"><dir name="View"><file name="Attributes.php" hash="4e2ce1107fc421d14b185deb260b821f"/></dir></dir></dir><file name="Donation.php" hash="790d2845de0898cb0d7c6bbdb7f3ad2a"/></dir><dir name="Helper"><file name="Data.php" hash="f9f6c2f684449162f5a87546a97a99fe"/></dir><dir name="etc"><file name="adminhtml.xml" hash="49f12a6c9db1c58c8bfff4e7a6d7ce51"/><file name="config.xml" hash="6495d1208b32cd1fa815e35f6b170b9f"/><file name="system.xml" hash="a51ee0bc8f796921899af54ff9ebe18d"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Beckin_WeightAttribute.xml" hash="5587f7599242ef2d2a9d2b535fd17105"/></dir></target></contents>
|
| 26 |
+
<compatible/>
|
| 27 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 28 |
+
</package>
|
