Version Notes
stable version for admin
Download this release
Release Info
Developer | SSTech |
Extension | SSTech_ViewProduct |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/SSTech/ViewProduct/Block/Abstract.php +60 -0
- app/code/community/SSTech/ViewProduct/Block/Catalog/Product.php +42 -0
- app/code/community/SSTech/ViewProduct/Helper/Data.php +5 -0
- app/code/community/SSTech/ViewProduct/etc/adminhtml.xml +23 -0
- app/code/community/SSTech/ViewProduct/etc/config.xml +52 -0
- app/code/community/SSTech/ViewProduct/etc/system.xml +42 -0
- app/design/adminhtml/default/default/layout/viewproduct.xml +9 -0
- app/design/adminhtml/default/default/template/viewproduct/view.phtml +18 -0
- package.xml +18 -0
app/code/community/SSTech/ViewProduct/Block/Abstract.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class SSTech_ViewProduct_Block_Abstract extends Mage_Adminhtml_Block_Template
|
4 |
+
{
|
5 |
+
abstract public function shouldAddButton();
|
6 |
+
abstract public function getItemType();
|
7 |
+
abstract public function getItemUrl();
|
8 |
+
|
9 |
+
public function getButtonId()
|
10 |
+
{
|
11 |
+
return 'sstech.view-button';
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getButtonHtml()
|
15 |
+
{
|
16 |
+
$buttonenable = Mage::getStoreConfig('viewproduct/settings/view_column_enabled');
|
17 |
+
if($buttonenable == "1"){
|
18 |
+
$buttonHtml = '<button class="scalable form-button" type="button" id="%s"><span>View %s</span></button>';
|
19 |
+
$buttonHtml = '<a href="%s" class="form-button" id="%s" target="_blank" style="margin-left: 5px; padding: 3px 8px 2px; position: relative; text-decoration: none; top: 1px;"><span>%s</span></a>';
|
20 |
+
}
|
21 |
+
return addslashes(sprintf($buttonHtml, $this->getItemUrl(), $this->getButtonId(), $this->getButtonLabel()));
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getButtonLabel()
|
25 |
+
{
|
26 |
+
return $this->__('View %s', $this->getItemType());
|
27 |
+
}
|
28 |
+
|
29 |
+
|
30 |
+
public function getPrimaryStore()
|
31 |
+
{
|
32 |
+
if (!$this->hasPrimaryStore()) {
|
33 |
+
$this->setPrimaryStore(false);
|
34 |
+
$websites = Mage::getResourceModel('core/website_collection');
|
35 |
+
|
36 |
+
foreach($websites as $website) {
|
37 |
+
if ($website->getIsDefault()) {
|
38 |
+
$this->setPrimaryStore($website->getDefaultStore());
|
39 |
+
break;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
return $this->getData('primary_store');
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getStore()
|
48 |
+
{
|
49 |
+
if ($storeId = $this->getRequest()->getParam('store', false)) {
|
50 |
+
$currentStore = Mage::getModel('core/store')->load($storeId);
|
51 |
+
|
52 |
+
if ($currentStore->getCode() != 'admin') {
|
53 |
+
return $currentStore;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
return $this->getPrimaryStore();
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
app/code/community/SSTech/ViewProduct/Block/Catalog/Product.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SSTech_ViewProduct_Block_Catalog_Product extends SSTech_ViewProduct_Block_Abstract
|
4 |
+
{
|
5 |
+
public function getItemType()
|
6 |
+
{
|
7 |
+
return 'Product';
|
8 |
+
}
|
9 |
+
|
10 |
+
public function shouldAddButton()
|
11 |
+
{
|
12 |
+
return $this->getRequest()->getParam('id', false) && $this->getItemUrl();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getItemUrl()
|
16 |
+
{
|
17 |
+
if (!$this->hasItemUrl()) {
|
18 |
+
$this->setItemUrl(false);
|
19 |
+
|
20 |
+
if ($this->getProduct() && $this->canShow($this->getProduct())) {
|
21 |
+
if ($this->getStore()) {
|
22 |
+
$this->getProduct()->setStoreId($this->getStore()->getId());
|
23 |
+
}
|
24 |
+
|
25 |
+
$itemUrl = $this->getProduct()->getProductUrl();
|
26 |
+
|
27 |
+
$this->setItemUrl($itemUrl);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
return $this->getData('item_url');
|
32 |
+
}
|
33 |
+
public function getProduct()
|
34 |
+
{
|
35 |
+
return Mage::registry('product');
|
36 |
+
}
|
37 |
+
public function canShow(Mage_Catalog_Model_Product $product)
|
38 |
+
{
|
39 |
+
return is_object($product) && $product->getId()
|
40 |
+
&& in_array($product->getVisibility(), array(2,4)) && $product->getStatus() == 1;
|
41 |
+
}
|
42 |
+
}
|
app/code/community/SSTech/ViewProduct/Helper/Data.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class SSTech_ViewProduct_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
5 |
+
|
app/code/community/SSTech/ViewProduct/etc/adminhtml.xml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<viewproduct translate="title" module="viewproduct">
|
12 |
+
<title>View Product Section</title>
|
13 |
+
<sort_order>0</sort_order>
|
14 |
+
</viewproduct>
|
15 |
+
</children>
|
16 |
+
</config>
|
17 |
+
</children>
|
18 |
+
</system>
|
19 |
+
</children>
|
20 |
+
</admin>
|
21 |
+
</resources>
|
22 |
+
</acl>
|
23 |
+
</config>
|
app/code/community/SSTech/ViewProduct/etc/config.xml
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<SSTech_ViewProduct>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</SSTech_ViewProduct>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<blocks>
|
10 |
+
<viewProduct>
|
11 |
+
<class>SSTech_ViewProduct_Block</class>
|
12 |
+
</viewProduct>
|
13 |
+
</blocks>
|
14 |
+
<helpers>
|
15 |
+
<viewproduct>
|
16 |
+
<class>SSTech_ViewProduct_Helper</class>
|
17 |
+
</viewproduct>
|
18 |
+
</helpers>
|
19 |
+
</global>
|
20 |
+
<adminhtml>
|
21 |
+
<layout>
|
22 |
+
<updates>
|
23 |
+
<viewProduct>
|
24 |
+
<file>viewproduct.xml</file>
|
25 |
+
</viewProduct>
|
26 |
+
</updates>
|
27 |
+
</layout>
|
28 |
+
|
29 |
+
<acl>
|
30 |
+
<resources>
|
31 |
+
<all>
|
32 |
+
<title>Allow Everything</title>
|
33 |
+
</all>
|
34 |
+
<admin>
|
35 |
+
<children>
|
36 |
+
<system>
|
37 |
+
<children>
|
38 |
+
<config>
|
39 |
+
<children>
|
40 |
+
<inchoo>
|
41 |
+
<title>SSTech</title>
|
42 |
+
</inchoo>
|
43 |
+
</children>
|
44 |
+
</config>
|
45 |
+
</children>
|
46 |
+
</system>
|
47 |
+
</children>
|
48 |
+
</admin>
|
49 |
+
</resources>
|
50 |
+
</acl>
|
51 |
+
</adminhtml>
|
52 |
+
</config>
|
app/code/community/SSTech/ViewProduct/etc/system.xml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<viewproduct translate="label" module="viewproduct">
|
5 |
+
<label>SSTech</label>
|
6 |
+
<sort_order>102</sort_order>
|
7 |
+
</viewproduct>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<viewproduct translate="label" module="viewproduct">
|
11 |
+
<label>View Product</label>
|
12 |
+
<tab>viewproduct</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>110</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>0</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<settings translate="label">
|
20 |
+
<label>View Product Button in Admin</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>1</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>0</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<view_column_enabled translate="label">
|
28 |
+
<label>Enabled</label>
|
29 |
+
<frontend_type>select</frontend_type>
|
30 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
31 |
+
<sort_order>20</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
<comment><![CDATA[Enable to show button in admin on product view page]]></comment>
|
36 |
+
</view_column_enabled>
|
37 |
+
</fields>
|
38 |
+
</settings>
|
39 |
+
</groups>
|
40 |
+
</viewproduct>
|
41 |
+
</sections>
|
42 |
+
</config>
|
app/design/adminhtml/default/default/layout/viewproduct.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<adminhtml_catalog_product_edit>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="viewProduct/catalog_product" before="-" name="preview_button.catalog.product" template="viewproduct/view.phtml" />
|
6 |
+
</reference>
|
7 |
+
</adminhtml_catalog_product_edit>
|
8 |
+
|
9 |
+
</layout>
|
app/design/adminhtml/default/default/template/viewproduct/view.phtml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php if ($this->shouldAddButton()): ?>
|
2 |
+
<?php $itemUrl = $this->getItemUrl() ?>
|
3 |
+
<?php if ($itemUrl): ?>
|
4 |
+
<script type="text/javascript">
|
5 |
+
//<![CDATA[
|
6 |
+
document.observe("dom:loaded", function() {
|
7 |
+
try {
|
8 |
+
var backBtn = $$('.content-header .form-buttons button')[0];
|
9 |
+
if (backBtn.id) {
|
10 |
+
backBtn.insert({after : '<?php echo $this->getButtonHtml() ?>'});
|
11 |
+
}
|
12 |
+
}
|
13 |
+
catch (e) {}
|
14 |
+
});
|
15 |
+
//]]>
|
16 |
+
</script>
|
17 |
+
<?php endif; ?>
|
18 |
+
<?php endif; ?>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>SSTech_ViewProduct</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>Open Source License</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Extension which able to view product directly from catalog product admin </summary>
|
10 |
+
<description>Extension which will allow to show the product directly from catalog product admin </description>
|
11 |
+
<notes>stable version for admin</notes>
|
12 |
+
<authors><author><name>Stek</name><user>SSTech</user><email>sandynareshg@gmail.com</email></author></authors>
|
13 |
+
<date>2014-06-21</date>
|
14 |
+
<time>08:09:28</time>
|
15 |
+
<contents><target name="mageetc"><dir name="."><file name="SSTech_ViewProduct.xml" hash=""/></dir></target><target name="magecommunity"><dir name="SSTech"><dir name="ViewProduct"><dir name="Block"><file name="Abstract.php" hash="f7cef893321846867638f06181f5e3c8"/><dir name="Catalog"><file name="Product.php" hash="951fad575e0b3c86642a32cd6aee0bbb"/></dir></dir><dir name="Helper"><file name="Data.php" hash="8f2d35c3ecf75843b0a694c84e405560"/></dir><dir name="etc"><file name="adminhtml.xml" hash="eb96fb04c5d9ba3023ba3316e5057c33"/><file name="config.xml" hash="84d1d248c4f1af62b7a83b9bfb20f9d6"/><file name="system.xml" hash="30f21ffc2b7c05abe999fb5d7000166c"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="viewproduct.xml" hash="be81ec765ca5e5fe688d08b5db46eb30"/></dir><dir name="template"><dir name="viewproduct"><file name="view.phtml" hash="43c457eeedbd99a4b329c8b81a5f7a57"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|