Version Notes
Custom Product Block Stable Version Release By ArtifexOnline.
Download this release
Release Info
| Developer | Artifex Online |
| Extension | magento-community-AO-custom-block |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/local/Artifex/Productblock/Block/Adminhtml/Catalog/Product/Tab.php +57 -0
- app/code/local/Artifex/Productblock/Helper/Data.php +5 -0
- app/code/local/Artifex/Productblock/Model/Cblock.php +9 -0
- app/code/local/Artifex/Productblock/Model/Observer.php +62 -0
- app/code/local/Artifex/Productblock/Model/Resource/Cblock.php +8 -0
- app/code/local/Artifex/Productblock/Model/Resource/Cblock/Collection.php +8 -0
- app/code/local/Artifex/Productblock/etc/config.xml +95 -0
- app/code/local/Artifex/Productblock/etc/system.xml +43 -0
- app/code/local/Artifex/Productblock/sql/artifex_productblock_setup/install-0.1.0.php +26 -0
- app/design/adminhtml/default/default/layout/customtabs.xml +30 -0
- app/design/adminhtml/default/default/template/productblock/catalog/product/tab.phtml +51 -0
- app/design/frontend/base/default/layout/productblock.xml +8 -0
- app/design/frontend/base/default/template/productblock/catalog/product/customblock.phtml +25 -0
- app/etc/modules/Artifex_Productblock.xml +9 -0
- package.xml +18 -0
- skin/adminhtml/default/default/ao.css +13 -0
- skin/adminhtml/default/default/images/index.ico +0 -0
app/code/local/Artifex/Productblock/Block/Adminhtml/Catalog/Product/Tab.php
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Artifex_Productblock_Block_Adminhtml_Catalog_Product_Tab
|
| 3 |
+
extends Mage_Adminhtml_Block_Template
|
| 4 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface {
|
| 5 |
+
/**
|
| 6 |
+
* Set the template for the block
|
| 7 |
+
*
|
| 8 |
+
*/
|
| 9 |
+
public function _construct()
|
| 10 |
+
{
|
| 11 |
+
parent::_construct();
|
| 12 |
+
$this->setTemplate('productblock/catalog/product/tab.phtml');
|
| 13 |
+
}
|
| 14 |
+
/**
|
| 15 |
+
* Retrieve the label used for the tab relating to this block
|
| 16 |
+
*
|
| 17 |
+
* @return string
|
| 18 |
+
*/
|
| 19 |
+
public function getTabLabel()
|
| 20 |
+
{
|
| 21 |
+
return $this->__('Custom Product Tab');
|
| 22 |
+
}
|
| 23 |
+
/**
|
| 24 |
+
* Retrieve the title used by this tab
|
| 25 |
+
*
|
| 26 |
+
* @return string
|
| 27 |
+
*/
|
| 28 |
+
public function getTabTitle()
|
| 29 |
+
{
|
| 30 |
+
return $this->__('Add block for product');
|
| 31 |
+
}
|
| 32 |
+
/**
|
| 33 |
+
* Determines whether to display the tab
|
| 34 |
+
* Add logic here to decide whether you want the tab to display
|
| 35 |
+
*
|
| 36 |
+
* @return bool
|
| 37 |
+
*/
|
| 38 |
+
public function canShowTab()
|
| 39 |
+
{
|
| 40 |
+
return true;
|
| 41 |
+
}
|
| 42 |
+
/**
|
| 43 |
+
* Stops the tab being hidden
|
| 44 |
+
*
|
| 45 |
+
* @return bool
|
| 46 |
+
*/
|
| 47 |
+
public function isHidden()
|
| 48 |
+
{
|
| 49 |
+
return false;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
public function getTabClass()
|
| 53 |
+
{
|
| 54 |
+
return 'artifex-custom-block';
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
}
|
app/code/local/Artifex/Productblock/Helper/Data.php
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Artifex_Productblock_Helper_Data extends Mage_Core_Helper_Abstract
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
}
|
app/code/local/Artifex/Productblock/Model/Cblock.php
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Artifex_Productblock_Model_Cblock extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
protected function _construct()
|
| 6 |
+
{
|
| 7 |
+
$this->_init('artifex_productblock/cblock');
|
| 8 |
+
}
|
| 9 |
+
}
|
app/code/local/Artifex/Productblock/Model/Observer.php
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Artifex_Productblock_Model_Observer
|
| 3 |
+
{
|
| 4 |
+
static protected $_singletonFlag = false;
|
| 5 |
+
public function saveProductTabData(Varien_Event_Observer $observer)
|
| 6 |
+
{
|
| 7 |
+
if (!self::$_singletonFlag) {
|
| 8 |
+
self::$_singletonFlag = true;
|
| 9 |
+
$product = $observer->getEvent()->getProduct();
|
| 10 |
+
try {
|
| 11 |
+
$customFieldValue = $this->_getRequest()->getPost('custom_list');
|
| 12 |
+
if($customFieldValue == null)
|
| 13 |
+
return;
|
| 14 |
+
$block = Mage::getModel('cms/block')->load($customFieldValue);
|
| 15 |
+
$blockname = $block->getTitle();
|
| 16 |
+
|
| 17 |
+
$product1 = Mage::registry('product')->getId();
|
| 18 |
+
|
| 19 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 20 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 21 |
+
|
| 22 |
+
$results = $read->fetchAll("select product_id from artifex_productblock_cblock where product_id = '$product1'");
|
| 23 |
+
|
| 24 |
+
if($results[0]['product_id'] == $product1)
|
| 25 |
+
{
|
| 26 |
+
$write->update(
|
| 27 |
+
"artifex_productblock_cblock",
|
| 28 |
+
array("product_id" => $product1, "custom_block_id" => $customFieldValue,"custom_block_name" => $blockname),
|
| 29 |
+
"product_id=$product1"
|
| 30 |
+
);
|
| 31 |
+
}else
|
| 32 |
+
{
|
| 33 |
+
$write->insert(
|
| 34 |
+
"artifex_productblock_cblock",
|
| 35 |
+
array("product_id" => $product1, "custom_block_id" => $customFieldValue,"custom_block_name" => $blockname)
|
| 36 |
+
);
|
| 37 |
+
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
catch (Exception $e) {
|
| 41 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
}
|
| 45 |
+
/**
|
| 46 |
+
* Retrieve the product model
|
| 47 |
+
*
|
| 48 |
+
* @return Mage_Catalog_Model_Product $product
|
| 49 |
+
*/
|
| 50 |
+
public function getProduct()
|
| 51 |
+
{
|
| 52 |
+
return Mage::registry('product');
|
| 53 |
+
}
|
| 54 |
+
/**
|
| 55 |
+
* Shortcut to getRequest
|
| 56 |
+
*
|
| 57 |
+
*/
|
| 58 |
+
protected function _getRequest()
|
| 59 |
+
{
|
| 60 |
+
return Mage::app()->getRequest();
|
| 61 |
+
}
|
| 62 |
+
}
|
app/code/local/Artifex/Productblock/Model/Resource/Cblock.php
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Artifex_Productblock_Model_Resource_Cblock extends Mage_Core_Model_Resource_Db_Abstract
|
| 3 |
+
{
|
| 4 |
+
protected function _construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_init('artifex_productblock/cblock', 'cblock_id');
|
| 7 |
+
}
|
| 8 |
+
}
|
app/code/local/Artifex/Productblock/Model/Resource/Cblock/Collection.php
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class Artifex_Productblock_Model_Resource_Cblock_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
| 3 |
+
{
|
| 4 |
+
public function _construct()
|
| 5 |
+
{
|
| 6 |
+
$this->_init('artifex_productblock/cblock');
|
| 7 |
+
}
|
| 8 |
+
}
|
app/code/local/Artifex/Productblock/etc/config.xml
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Artifex_Productblock>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</Artifex_Productblock>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<blocks>
|
| 10 |
+
<productblock>
|
| 11 |
+
<class>Artifex_Productblock_Block</class>
|
| 12 |
+
</productblock>
|
| 13 |
+
</blocks>
|
| 14 |
+
<models>
|
| 15 |
+
<productblock>
|
| 16 |
+
<class>Artifex_Productblock_Model</class>
|
| 17 |
+
</productblock>
|
| 18 |
+
<artifex_productblock>
|
| 19 |
+
<class>Artifex_Productblock_Model</class>
|
| 20 |
+
<resourceModel>artifex_productblock_resource</resourceModel>
|
| 21 |
+
</artifex_productblock>
|
| 22 |
+
<artifex_productblock_resource>
|
| 23 |
+
<class>Artifex_Productblock_Model_Resource</class>
|
| 24 |
+
<entities>
|
| 25 |
+
<cblock>
|
| 26 |
+
<table>artifex_productblock_cblock</table>
|
| 27 |
+
</cblock>
|
| 28 |
+
</entities>
|
| 29 |
+
</artifex_productblock_resource>
|
| 30 |
+
</models>
|
| 31 |
+
<resources>
|
| 32 |
+
<artifex_productblock_setup>
|
| 33 |
+
<setup>
|
| 34 |
+
<module>Artifex_Productblock</module>
|
| 35 |
+
</setup>
|
| 36 |
+
</artifex_productblock_setup>
|
| 37 |
+
</resources>
|
| 38 |
+
<helpers>
|
| 39 |
+
<productblock>
|
| 40 |
+
<class>Artifex_Productblock_Helper</class>
|
| 41 |
+
</productblock>
|
| 42 |
+
</helpers>
|
| 43 |
+
</global>
|
| 44 |
+
<frontend>
|
| 45 |
+
<layout> <!-- definition of layout update for frontend area -->
|
| 46 |
+
<updates>
|
| 47 |
+
<productblock>
|
| 48 |
+
<file>productblock.xml</file>
|
| 49 |
+
</productblock>
|
| 50 |
+
</updates>
|
| 51 |
+
</layout>
|
| 52 |
+
</frontend>
|
| 53 |
+
<adminhtml>
|
| 54 |
+
<layout>
|
| 55 |
+
<updates>
|
| 56 |
+
<productblock>
|
| 57 |
+
<file>customtabs.xml</file>
|
| 58 |
+
</productblock>
|
| 59 |
+
</updates>
|
| 60 |
+
</layout>
|
| 61 |
+
<events>
|
| 62 |
+
<catalog_product_save_after>
|
| 63 |
+
<observers>
|
| 64 |
+
<productblock_save_product_data>
|
| 65 |
+
<type>singleton</type>
|
| 66 |
+
<class>productblock/observer</class>
|
| 67 |
+
<method>saveProductTabData</method>
|
| 68 |
+
</productblock_save_product_data>
|
| 69 |
+
</observers>
|
| 70 |
+
</catalog_product_save_after>
|
| 71 |
+
</events>
|
| 72 |
+
<acl>
|
| 73 |
+
<resources>
|
| 74 |
+
<all>
|
| 75 |
+
<title>Allow Everything</title>
|
| 76 |
+
</all>
|
| 77 |
+
<admin>
|
| 78 |
+
<children>
|
| 79 |
+
<system>
|
| 80 |
+
<children>
|
| 81 |
+
<config>
|
| 82 |
+
<children>
|
| 83 |
+
<artifex>
|
| 84 |
+
<title>Artifex - All</title>
|
| 85 |
+
</artifex>
|
| 86 |
+
</children>
|
| 87 |
+
</config>
|
| 88 |
+
</children>
|
| 89 |
+
</system>
|
| 90 |
+
</children>
|
| 91 |
+
</admin>
|
| 92 |
+
</resources>
|
| 93 |
+
</acl>
|
| 94 |
+
</adminhtml>
|
| 95 |
+
</config>
|
app/code/local/Artifex/Productblock/etc/system.xml
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
| 2 |
+
<config>
|
| 3 |
+
<tabs>
|
| 4 |
+
<artifex translate="label" module="productblock">
|
| 5 |
+
<label>Artifex-online Extensions</label>
|
| 6 |
+
<sort_order>100</sort_order>
|
| 7 |
+
<class>artifex-custom-block</class>
|
| 8 |
+
</artifex>
|
| 9 |
+
</tabs>
|
| 10 |
+
<sections>
|
| 11 |
+
<artifex translate="label" module="productblock">
|
| 12 |
+
<label>Product Block Options</label>
|
| 13 |
+
<tab>artifex</tab>
|
| 14 |
+
<sort_order>1000</sort_order>
|
| 15 |
+
<show_in_default>1</show_in_default>
|
| 16 |
+
<show_in_website>1</show_in_website>
|
| 17 |
+
<show_in_store>1</show_in_store>
|
| 18 |
+
|
| 19 |
+
<groups>
|
| 20 |
+
<artifex_group translate="label" module="productblock">
|
| 21 |
+
<label>AO Product Block Options</label>
|
| 22 |
+
<frontend_type>text</frontend_type>
|
| 23 |
+
<sort_order>1000</sort_order>
|
| 24 |
+
<show_in_default>1</show_in_default>
|
| 25 |
+
<show_in_website>1</show_in_website>
|
| 26 |
+
<show_in_store>1</show_in_store>
|
| 27 |
+
<fields>
|
| 28 |
+
<artifex_select translate="label">
|
| 29 |
+
<label>Enable </label>
|
| 30 |
+
<comment>Enable/Disable Extension</comment>
|
| 31 |
+
<frontend_type>select</frontend_type>
|
| 32 |
+
<sort_order>90</sort_order>
|
| 33 |
+
<show_in_default>1</show_in_default>
|
| 34 |
+
<show_in_website>1</show_in_website>
|
| 35 |
+
<show_in_store>1</show_in_store>
|
| 36 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 37 |
+
</artifex_select>
|
| 38 |
+
</fields>
|
| 39 |
+
</artifex_group>
|
| 40 |
+
</groups>
|
| 41 |
+
</artifex>
|
| 42 |
+
</sections>
|
| 43 |
+
</config>
|
app/code/local/Artifex/Productblock/sql/artifex_productblock_setup/install-0.1.0.php
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
$installer = $this;
|
| 4 |
+
|
| 5 |
+
$installer->startSetup();
|
| 6 |
+
|
| 7 |
+
$table = $installer->getConnection()
|
| 8 |
+
->newTable($installer->getTable('artifex_productblock/cblock'))
|
| 9 |
+
->addColumn('cblock_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
| 10 |
+
'identity' => true,
|
| 11 |
+
'unsigned' => true,
|
| 12 |
+
'nullable' => false,
|
| 13 |
+
'primary' => true,
|
| 14 |
+
), 'Id')
|
| 15 |
+
->addColumn('product_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
|
| 16 |
+
'nullable' => false,
|
| 17 |
+
), 'Product Id')
|
| 18 |
+
->addColumn('custom_block_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
|
| 19 |
+
'nullable' => false,
|
| 20 |
+
), 'Custom Block Id')
|
| 21 |
+
->addColumn('custom_block_name', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
|
| 22 |
+
'nullable' => false,
|
| 23 |
+
), 'Custom Block Name');
|
| 24 |
+
|
| 25 |
+
$installer->getConnection()->createTable($table);
|
| 26 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/customtabs.xml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout>
|
| 3 |
+
<adminhtml_catalog_product_edit>
|
| 4 |
+
<reference name="product_tabs">
|
| 5 |
+
<action method="addTab">
|
| 6 |
+
<name>custom_product_tab</name>
|
| 7 |
+
<block>productblock/adminhtml_catalog_product_tab</block>
|
| 8 |
+
</action>
|
| 9 |
+
</reference>
|
| 10 |
+
<reference name="head">
|
| 11 |
+
<action method="addCss"><name>ao.css</name></action>
|
| 12 |
+
</reference>
|
| 13 |
+
</adminhtml_catalog_product_edit>
|
| 14 |
+
<adminhtml_catalog_product_new>
|
| 15 |
+
<reference name="product_tabs">
|
| 16 |
+
<action method="addTab">
|
| 17 |
+
<name>custom_product_tab</name>
|
| 18 |
+
<block>productblock/adminhtml_catalog_product_tab</block>
|
| 19 |
+
</action>
|
| 20 |
+
</reference>
|
| 21 |
+
<reference name="head">
|
| 22 |
+
<action method="addCss"><name>ao.css</name></action>
|
| 23 |
+
</reference>
|
| 24 |
+
</adminhtml_catalog_product_new>
|
| 25 |
+
<adminhtml_system_config_edit>
|
| 26 |
+
<reference name="head">
|
| 27 |
+
<action method="addCss"><name>ao.css</name></action>
|
| 28 |
+
</reference>
|
| 29 |
+
</adminhtml_system_config_edit>
|
| 30 |
+
</layout>
|
app/design/adminhtml/default/default/template/productblock/catalog/product/tab.phtml
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$activ = Mage::getStoreConfig('artifex/artifex_group/artifex_select',Mage::app()->getStore());
|
| 3 |
+
if($activ == 1)
|
| 4 |
+
{
|
| 5 |
+
?>
|
| 6 |
+
<div class="input-field custom-blk">
|
| 7 |
+
<?php
|
| 8 |
+
$productId = Mage::registry('current_product')->getId();
|
| 9 |
+
$collection = Mage::getModel('artifex_productblock/cblock')->getCollection()->addFieldToFilter('product_id', $productId);
|
| 10 |
+
|
| 11 |
+
foreach($collection as $data){
|
| 12 |
+
?>
|
| 13 |
+
<div class="selected-block">
|
| 14 |
+
<label>Your selected block name is :</label><span id="artcname"><?php print_r($data->getCustom_block_name());?></span>
|
| 15 |
+
</div>
|
| 16 |
+
<?php
|
| 17 |
+
}
|
| 18 |
+
?>
|
| 19 |
+
<div class="select-block">
|
| 20 |
+
<label for="custom_field">Select OR Chang Static Block For Product</label>
|
| 21 |
+
<?php
|
| 22 |
+
$collection = Mage::getModel('cms/block')->getCollection()->addFieldToFilter('is_active', 1);
|
| 23 |
+
?>
|
| 24 |
+
<select id="custom_opti" name="custom_list">
|
| 25 |
+
<option value=""></option>
|
| 26 |
+
<option value="0">Remove selected Block</option>
|
| 27 |
+
<?php
|
| 28 |
+
foreach($collection as $list)
|
| 29 |
+
{
|
| 30 |
+
?>
|
| 31 |
+
<option value="<?php echo $list->getId(); ?>"><?php echo $list->getTitle(); ?></option>
|
| 32 |
+
<?php
|
| 33 |
+
}
|
| 34 |
+
?>
|
| 35 |
+
</select>
|
| 36 |
+
</div>
|
| 37 |
+
</div>
|
| 38 |
+
<?php
|
| 39 |
+
}
|
| 40 |
+
?>
|
| 41 |
+
<script type="text/javascript">
|
| 42 |
+
var v = $$('#artcname').first().innerHTML;
|
| 43 |
+
var options = $$('select#custom_opti option');
|
| 44 |
+
var len = options.length;
|
| 45 |
+
for (var i = 0; i < len; i++) {
|
| 46 |
+
var xyz = options[i].text;
|
| 47 |
+
if(xyz == v){
|
| 48 |
+
options[i].selected = true;
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
</script>
|
app/design/frontend/base/default/layout/productblock.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<catalog_product_view translate="label">
|
| 4 |
+
<reference name="right">
|
| 5 |
+
<block type="core/template" before="-" template="productblock/catalog/product/customblock.phtml"/>
|
| 6 |
+
</reference>
|
| 7 |
+
</catalog_product_view>
|
| 8 |
+
</layout>
|
app/design/frontend/base/default/template/productblock/catalog/product/customblock.phtml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$activ = Mage::getStoreConfig('artifex/artifex_group/artifex_select',Mage::app()->getStore());
|
| 3 |
+
if($activ == 1)
|
| 4 |
+
{
|
| 5 |
+
$currentproduct = Mage::registry('current_product');
|
| 6 |
+
// general product data
|
| 7 |
+
$product_id = $currentproduct->getId();
|
| 8 |
+
//echo $currentproduct->getName();
|
| 9 |
+
|
| 10 |
+
$read = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 11 |
+
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
|
| 12 |
+
|
| 13 |
+
$results = $read->fetchAll("select custom_block_id from artifex_productblock_cblock where product_id = '$product_id'");
|
| 14 |
+
$customblock = $results[0]['custom_block_id'];
|
| 15 |
+
|
| 16 |
+
if($results == null)
|
| 17 |
+
{
|
| 18 |
+
// echo "no data found";
|
| 19 |
+
}else
|
| 20 |
+
{
|
| 21 |
+
|
| 22 |
+
echo $this->getLayout()->createBlock("cms/block")->setBlockId($customblock)->toHtml();
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
?>
|
app/etc/modules/Artifex_Productblock.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Artifex_Productblock>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
</Artifex_Productblock>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>AO_Custom_Product_Block</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license>osl</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Custom Product Block</summary>
|
| 10 |
+
<description>Display Your Product Block on Product Detail Page.</description>
|
| 11 |
+
<notes>Custom Product Block Stable Version Release By ArtifexOnline. </notes>
|
| 12 |
+
<authors><author><name>Artifex Online</name><user>artifexonline</user><email>info@artifex-online.com</email></author></authors>
|
| 13 |
+
<date>2016-02-23</date>
|
| 14 |
+
<time>05:55:32</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="Artifex"><dir name="Productblock"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><file name="Tab.php" hash="a960e306286aa1a95cb171ad7ef1e71f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="a09de0e2c206b33f87b60838d983c4c5"/></dir><dir name="Model"><file name="Cblock.php" hash="e5571ced6a44d33a8c4c9298622d36fa"/><file name="Observer.php" hash="caadb5639174ba3f87a60c0439ee7b42"/><dir name="Resource"><dir name="Cblock"><file name="Collection.php" hash="9bc54d08f189380e06d8c99d1200df2f"/></dir><file name="Cblock.php" hash="de392199e8f05d429118cbb893e37435"/></dir></dir><dir name="etc"><file name="config.xml" hash="37d3a09143adfa8a749f479c1186c3e5"/><file name="system.xml" hash="b88051a83093151fbe1abd5188d191df"/></dir><dir name="sql"><dir name="artifex_productblock_setup"><file name="install-0.1.0.php" hash="9c5f0fc28f3c914c9960f60334f09d7f"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Artifex_Productblock.xml" hash="deda82cdf55d48279f3ab1e252dc4581"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="customtabs.xml" hash="ef6fee537e17005e06477fa99baff335"/></dir><dir name="template"><dir name="productblock"><dir name="catalog"><dir name="product"><file name="tab.phtml" hash="766c91e5d90042213f12f48fc2f36069"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="productblock.xml" hash="e005bbaef7780fb447e7515e50528bf2"/></dir><dir name="template"><dir name="productblock"><dir name="catalog"><dir name="product"><file name="customblock.phtml" hash="1827cc31fb71e9fabe643d37a992cb4f"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><file name="index.ico" hash="5f3ea41018f28079db65bfbed9473b38"/></dir><file name="ao.css" hash="b5b151638688699b3b23a8d004229d47"/></dir></dir></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
+
</package>
|
skin/adminhtml/default/default/ao.css
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*========================= Custom Block =========================*/
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
.custom-blk{}
|
| 5 |
+
.custom-blk .selected-block{ font-size:14px; margin-bottom:40px;}
|
| 6 |
+
.custom-blk .selected-block span{ font-size16px; font-weight:bold;}
|
| 7 |
+
|
| 8 |
+
.custom-blk .select-block{ font-size:14px; padding:15px; border:1px solid #dfdfdf;}
|
| 9 |
+
.custom-blk .select-block select{ display:block; margin-top:10px; width:350px; height:28px;}
|
| 10 |
+
.custom-blk .select-block label{background: #6f8992 none repeat scroll 0 0; color: #fff; display: block; margin-bottom: 20px; margin-top: -30px; padding: 6px; width: 90%;}
|
| 11 |
+
|
| 12 |
+
.artifex-custom-block dl dt { background-image:url(images/index.ico); background-position: 98% center; background-repeat: no-repeat;}
|
| 13 |
+
#product_info_tabs .artifex-custom-block span{ background-image:url(images/index.ico); background-position: 95% center; background-repeat: no-repeat;}
|
skin/adminhtml/default/default/images/index.ico
ADDED
|
Binary file
|
