Version Notes
Direct Checkout
Download this release
Release Info
Developer | vishal4671 |
Extension | VJP_DirectCheckout |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/VJP/AttributeOptionImage/Block/Catalog/Product/Attribute/Edit/Tab/Options.php +70 -0
- app/code/community/VJP/AttributeOptionImage/Block/Catalog/Product/View/Attributes.php +59 -0
- app/code/community/VJP/AttributeOptionImage/Block/Catalog/Product/View/view.phtml +169 -0
- app/code/community/VJP/AttributeOptionImage/Helper/Cms/Wysiwyg/Images.php +13 -0
- app/code/community/VJP/AttributeOptionImage/Helper/Data.php +40 -0
- app/code/community/VJP/AttributeOptionImage/Model/Catalog/Resource/Eav/Mysql4/Attribute.php +87 -0
- app/code/community/VJP/AttributeOptionImage/Model/Eav/Entity/Attribute/Source/Table.php +36 -0
- app/code/community/VJP/AttributeOptionImage/Model/Eav/Mysql4/Entity/Attribute/Option.php +22 -0
- app/code/community/VJP/AttributeOptionImage/Model/Observer.php +36 -0
- app/code/community/VJP/AttributeOptionImage/controllers/Cms/Wysiwyg/ImagesController.php +20 -0
- app/code/community/VJP/AttributeOptionImage/etc/config.xml +93 -0
- app/code/community/VJP/AttributeOptionImage/sql/vjp_attributeoptionimage_setup/mysql4-install-1.0.0.php +14 -0
- app/code/community/VJP/AttributeOptionImage/sql/vjp_attributeoptionimage_setup/mysql4-upgrade-1.0.0-1.0.1.php +14 -0
- app/code/community/VJP/DirectCheckout/Block/DirectCheckout.php +7 -0
- app/code/community/VJP/DirectCheckout/controllers/Catalog/ProductController.php +39 -0
- app/code/community/VJP/DirectCheckout/controllers/Checkout/CartController.php +73 -0
- app/code/community/VJP/DirectCheckout/etc/config.xml +47 -0
- app/design/frontend/default/default/layout/directcheckout.xml +12 -0
- app/design/frontend/default/default/template/directcheckout/directcheckout.phtml +14 -0
- app/etc/modules/VJP_DirectCheckout.xml +9 -0
- package.xml +18 -0
app/code/community/VJP/AttributeOptionImage/Block/Catalog/Product/Attribute/Edit/Tab/Options.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VJP_AttributeOptionImage_Block_Catalog_Product_Attribute_Edit_Tab_Options extends Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setTemplate('vjp/catalog/product/attribute/options.phtml');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getOptionValues()
|
12 |
+
{
|
13 |
+
$attributeType = $this->getAttributeObject()->getFrontendInput();
|
14 |
+
$defaultValues = $this->getAttributeObject()->getDefaultValue();
|
15 |
+
if ($attributeType == 'select' || $attributeType == 'multiselect') {
|
16 |
+
$defaultValues = explode(',', $defaultValues);
|
17 |
+
} else {
|
18 |
+
$defaultValues = array();
|
19 |
+
}
|
20 |
+
|
21 |
+
switch ($attributeType) {
|
22 |
+
case 'select':
|
23 |
+
$inputType = 'radio';
|
24 |
+
break;
|
25 |
+
case 'multiselect':
|
26 |
+
$inputType = 'checkbox';
|
27 |
+
break;
|
28 |
+
default:
|
29 |
+
$inputType = '';
|
30 |
+
break;
|
31 |
+
}
|
32 |
+
|
33 |
+
$values = $this->getData('option_values');
|
34 |
+
if (is_null($values)) {
|
35 |
+
$values = array();
|
36 |
+
$optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
37 |
+
->setAttributeFilter($this->getAttributeObject()->getId())
|
38 |
+
->setPositionOrder('desc', true)
|
39 |
+
->load();
|
40 |
+
|
41 |
+
foreach ($optionCollection as $option) {
|
42 |
+
$value = array();
|
43 |
+
if (in_array($option->getId(), $defaultValues)) {
|
44 |
+
$value['checked'] = 'checked="checked"';
|
45 |
+
} else {
|
46 |
+
$value['checked'] = '';
|
47 |
+
}
|
48 |
+
|
49 |
+
$value['intype'] = $inputType;
|
50 |
+
$value['id'] = $option->getId();
|
51 |
+
$value['sort_order'] = $option->getSortOrder();
|
52 |
+
$value['image'] = $option->getImage();
|
53 |
+
$value['thumb'] = $option->getThumb();
|
54 |
+
foreach ($this->getStores() as $store) {
|
55 |
+
$storeValues = $this->getStoreOptionValues($store->getId());
|
56 |
+
if (isset($storeValues[$option->getId()])) {
|
57 |
+
$value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
|
58 |
+
}
|
59 |
+
else {
|
60 |
+
$value['store'.$store->getId()] = '';
|
61 |
+
}
|
62 |
+
}
|
63 |
+
$values[] = new Varien_Object($value);
|
64 |
+
}
|
65 |
+
$this->setData('option_values', $values);
|
66 |
+
}
|
67 |
+
|
68 |
+
return $values;
|
69 |
+
}
|
70 |
+
}
|
app/code/community/VJP/AttributeOptionImage/Block/Catalog/Product/View/Attributes.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Product description block
|
5 |
+
*
|
6 |
+
* @category Mage
|
7 |
+
* @package Mage_Catalog
|
8 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
9 |
+
*/
|
10 |
+
class VJP_AttributeOptionImage_Block_Product_View_Attributes extends Mage_Core_Block_Template
|
11 |
+
{
|
12 |
+
protected $_product = null;
|
13 |
+
|
14 |
+
function getProduct()
|
15 |
+
{
|
16 |
+
if (!$this->_product) {
|
17 |
+
$this->_product = Mage::registry('product');
|
18 |
+
}
|
19 |
+
return $this->_product;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* $excludeAttr is optional array of attribute codes to
|
24 |
+
* exclude them from additional data array
|
25 |
+
*
|
26 |
+
* @param array $excludeAttr
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
public function getAdditionalData(array $excludeAttr = array())
|
30 |
+
{
|
31 |
+
$data = array();
|
32 |
+
$product = $this->getProduct();
|
33 |
+
$attributes = $product->getAttributes();
|
34 |
+
foreach ($attributes as $attribute) {
|
35 |
+
// if ($attribute->getIsVisibleOnFront() && $attribute->getIsUserDefined() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
|
36 |
+
if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
|
37 |
+
$value = $attribute->getFrontend()->getValue($product);
|
38 |
+
|
39 |
+
if (!$product->hasData($attribute->getAttributeCode())) {
|
40 |
+
$value = Mage::helper('catalog')->__('N/A');
|
41 |
+
} elseif ((string)$value == '') {
|
42 |
+
$value = Mage::helper('catalog')->__('No');
|
43 |
+
} elseif ($attribute->getFrontendInput() == 'price' && is_string($value)) {
|
44 |
+
$value = Mage::app()->getStore()->convertPrice($value, true);
|
45 |
+
}
|
46 |
+
|
47 |
+
if (is_string($value) && strlen($value)) {
|
48 |
+
$data[$attribute->getAttributeCode()] = array(
|
49 |
+
'label' => $attribute->getStoreLabel(),
|
50 |
+
'value' => $value,
|
51 |
+
'code' => $attribute->getAttributeCode(),
|
52 |
+
'img' => Mage::helper('attributeoptionimage')->getAttributeOptionImage(3)
|
53 |
+
);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
return $data;
|
58 |
+
}
|
59 |
+
}
|
app/code/community/VJP/AttributeOptionImage/Block/Catalog/Product/View/view.phtml
ADDED
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Product view template
|
29 |
+
*
|
30 |
+
* @see Mage_Catalog_Block_Product_View
|
31 |
+
* @see Mage_Review_Block_Product_View
|
32 |
+
*/
|
33 |
+
?>
|
34 |
+
<?php $_helper = $this->helper('catalog/output'); ?>
|
35 |
+
<?php $_product = $this->getProduct(); ?>
|
36 |
+
<script type="text/javascript">
|
37 |
+
var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
|
38 |
+
</script>
|
39 |
+
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
|
40 |
+
<div class="product-view">
|
41 |
+
<div class="product-essential">
|
42 |
+
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
|
43 |
+
<div class="no-display">
|
44 |
+
<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
|
45 |
+
<input type="hidden" name="related_product" id="related-products-field" value="" />
|
46 |
+
</div>
|
47 |
+
|
48 |
+
<div class="product-shop">
|
49 |
+
<div class="product-name">
|
50 |
+
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
|
51 |
+
</div>
|
52 |
+
|
53 |
+
<?php if ($this->canEmailToFriend()): ?>
|
54 |
+
<p class="email-friend"><a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a></p>
|
55 |
+
<?php endif; ?>
|
56 |
+
|
57 |
+
<?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
|
58 |
+
<?php echo $this->getChildHtml('alert_urls') ?>
|
59 |
+
<?php echo $this->getChildHtml('product_type_data') ?>
|
60 |
+
<?php echo $this->getTierPriceHtml() ?>
|
61 |
+
<?php echo $this->getChildHtml('extrahint') ?>
|
62 |
+
|
63 |
+
<?php if (!$this->hasOptions()):?>
|
64 |
+
<div class="add-to-box">
|
65 |
+
<?php if($_product->isSaleable()): ?>
|
66 |
+
<?php echo $this->getChildHtml('addtocart') ?>
|
67 |
+
<?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
|
68 |
+
<span class="or"><?php echo $this->__('OR') ?></span>
|
69 |
+
<?php endif; ?>
|
70 |
+
<?php endif; ?>
|
71 |
+
<?php echo $this->getChildHtml('addto') ?>
|
72 |
+
</div>
|
73 |
+
<?php echo $this->getChildHtml('extra_buttons') ?>
|
74 |
+
<?php elseif (!$_product->isSaleable()): ?>
|
75 |
+
<div class="add-to-box">
|
76 |
+
<?php echo $this->getChildHtml('addto') ?>
|
77 |
+
</div>
|
78 |
+
<?php endif; ?>
|
79 |
+
|
80 |
+
<?php if ($_product->getShortDescription()):?>
|
81 |
+
<div class="short-description">
|
82 |
+
<h2><?php echo $this->__('Quick Overview') ?></h2>
|
83 |
+
<div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
|
84 |
+
</div>
|
85 |
+
<?php endif;?>
|
86 |
+
|
87 |
+
<?php echo $this->getChildHtml('other');?>
|
88 |
+
|
89 |
+
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
|
90 |
+
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
|
91 |
+
<?php endif;?>
|
92 |
+
|
93 |
+
</div>
|
94 |
+
|
95 |
+
<div class="product-img-box">
|
96 |
+
<?php echo $this->getChildHtml('media') ?>
|
97 |
+
</div>
|
98 |
+
|
99 |
+
<div class="clearer"></div>
|
100 |
+
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
|
101 |
+
<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
|
102 |
+
<?php endif;?>
|
103 |
+
</form>
|
104 |
+
<script type="text/javascript">
|
105 |
+
//<![CDATA[
|
106 |
+
var productAddToCartForm = new VarienForm('product_addtocart_form');
|
107 |
+
productAddToCartForm.submit = function(button, url) {
|
108 |
+
if (this.validator.validate()) {
|
109 |
+
var form = this.form;
|
110 |
+
var oldUrl = form.action;
|
111 |
+
|
112 |
+
if (url) {
|
113 |
+
form.action = url;
|
114 |
+
}
|
115 |
+
var e = null;
|
116 |
+
try {
|
117 |
+
this.form.submit();
|
118 |
+
} catch (e) {
|
119 |
+
}
|
120 |
+
this.form.action = oldUrl;
|
121 |
+
if (e) {
|
122 |
+
throw e;
|
123 |
+
}
|
124 |
+
|
125 |
+
if (button && button != 'undefined') {
|
126 |
+
button.disabled = true;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}.bind(productAddToCartForm);
|
130 |
+
|
131 |
+
productAddToCartForm.submitLight = function(button, url){
|
132 |
+
if(this.validator) {
|
133 |
+
var nv = Validation.methods;
|
134 |
+
delete Validation.methods['required-entry'];
|
135 |
+
delete Validation.methods['validate-one-required'];
|
136 |
+
delete Validation.methods['validate-one-required-by-name'];
|
137 |
+
// Remove custom datetime validators
|
138 |
+
for (var methodName in Validation.methods) {
|
139 |
+
if (methodName.match(/^validate-datetime-.*/i)) {
|
140 |
+
delete Validation.methods[methodName];
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
if (this.validator.validate()) {
|
145 |
+
if (url) {
|
146 |
+
this.form.action = url;
|
147 |
+
}
|
148 |
+
this.form.submit();
|
149 |
+
}
|
150 |
+
Object.extend(Validation.methods, nv);
|
151 |
+
}
|
152 |
+
}.bind(productAddToCartForm);
|
153 |
+
//]]>
|
154 |
+
</script>
|
155 |
+
</div>
|
156 |
+
|
157 |
+
<div class="product-collateral">
|
158 |
+
<?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
|
159 |
+
<div class="box-collateral <?php echo "box-{$alias}"?>">
|
160 |
+
<?php if ($title = $this->getChildData($alias, 'title')):?>
|
161 |
+
<h2><?php echo $this->escapeHtml($title); ?></h2>
|
162 |
+
<?php endif;?>
|
163 |
+
<?php echo $html; ?>
|
164 |
+
</div>
|
165 |
+
<?php endforeach;?>
|
166 |
+
<?php echo $this->getChildHtml('upsell_products') ?>
|
167 |
+
<?php echo $this->getChildHtml('product_additional_data') ?>
|
168 |
+
</div>
|
169 |
+
</div>
|
app/code/community/VJP/AttributeOptionImage/Helper/Cms/Wysiwyg/Images.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VJP_AttributeOptionImage_Helper_Cms_Wysiwyg_Images extends Mage_Cms_Helper_Wysiwyg_Images
|
4 |
+
{
|
5 |
+
public function isUsingStaticUrlsAllowed()
|
6 |
+
{
|
7 |
+
if (Mage::getSingleton('adminhtml/session')->getStaticUrlsAllowed()) {
|
8 |
+
return true;
|
9 |
+
}
|
10 |
+
|
11 |
+
return parent::isUsingStaticUrlsAllowed();
|
12 |
+
}
|
13 |
+
}
|
app/code/community/VJP/AttributeOptionImage/Helper/Data.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VJP_AttributeOptionImage_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
public function getAttributeOptionImage($optionId)
|
6 |
+
{
|
7 |
+
$images = $this->getAttributeOptionImages();
|
8 |
+
$image = array_key_exists($optionId, $images) ? $images[$optionId] : '';
|
9 |
+
if ($image && (strpos($image, 'http') !== 0)) {
|
10 |
+
$image = Mage::getDesign()->getSkinUrl($image);
|
11 |
+
}
|
12 |
+
|
13 |
+
return $image;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function getAttributeOptionImages()
|
17 |
+
{
|
18 |
+
$images = Mage::getResourceModel('eav/entity_attribute_option')->getAttributeOptionImages();
|
19 |
+
|
20 |
+
return $images;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function getAttributeOptionThumb($optionId)
|
24 |
+
{
|
25 |
+
$images = $this->getAttributeOptionThumbs();
|
26 |
+
$image = array_key_exists($optionId, $images) ? $images[$optionId] : '';
|
27 |
+
if ($image && (strpos($image, 'http') !== 0)) {
|
28 |
+
$image = Mage::getDesign()->getSkinUrl($image);
|
29 |
+
}
|
30 |
+
|
31 |
+
return $image;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getAttributeOptionThumbs()
|
35 |
+
{
|
36 |
+
$images = Mage::getResourceModel('eav/entity_attribute_option')->getAttributeOptionThumbs();
|
37 |
+
|
38 |
+
return $images;
|
39 |
+
}
|
40 |
+
}
|
app/code/community/VJP/AttributeOptionImage/Model/Catalog/Resource/Eav/Mysql4/Attribute.php
ADDED
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VJP_AttributeOptionImage_Model_Catalog_Resource_Eav_Mysql4_Attribute extends Mage_Catalog_Model_Resource_Eav_Mysql4_Attribute
|
4 |
+
{
|
5 |
+
protected function _saveOption(Mage_Core_Model_Abstract $object)
|
6 |
+
{
|
7 |
+
$option = $object->getOption();
|
8 |
+
if (is_array($option)) {
|
9 |
+
$write = $this->_getWriteAdapter();
|
10 |
+
$optionTable = $this->getTable('attribute_option');
|
11 |
+
$optionValueTable = $this->getTable('attribute_option_value');
|
12 |
+
$stores = Mage::getModel('core/store')
|
13 |
+
->getResourceCollection()
|
14 |
+
->setLoadDefault(true)
|
15 |
+
->load();
|
16 |
+
|
17 |
+
if (isset($option['value'])) {
|
18 |
+
$attributeDefaultValue = array();
|
19 |
+
if (!is_array($object->getDefault())) {
|
20 |
+
$object->setDefault(array());
|
21 |
+
}
|
22 |
+
|
23 |
+
foreach ($option['value'] as $optionId => $values) {
|
24 |
+
$intOptionId = (int) $optionId;
|
25 |
+
if (!empty($option['delete'][$optionId])) {
|
26 |
+
if ($intOptionId) {
|
27 |
+
$condition = $write->quoteInto('option_id=?', $intOptionId);
|
28 |
+
$write->delete($optionTable, $condition);
|
29 |
+
}
|
30 |
+
|
31 |
+
continue;
|
32 |
+
}
|
33 |
+
|
34 |
+
if (!$intOptionId) {
|
35 |
+
$data = array(
|
36 |
+
'attribute_id' => $object->getId(),
|
37 |
+
'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
|
38 |
+
'image' => isset($option['image'][$optionId]) ? $option['image'][$optionId] : '',
|
39 |
+
'thumb' => isset($option['thumb'][$optionId]) ? $option['thumb'][$optionId] : '',
|
40 |
+
);
|
41 |
+
$write->insert($optionTable, $data);
|
42 |
+
$intOptionId = $write->lastInsertId();
|
43 |
+
}
|
44 |
+
else {
|
45 |
+
$data = array(
|
46 |
+
'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
|
47 |
+
'image' => isset($option['image'][$optionId]) ? $option['image'][$optionId] : '',
|
48 |
+
'thumb' => isset($option['thumb'][$optionId]) ? $option['thumb'][$optionId] : '',
|
49 |
+
);
|
50 |
+
$write->update($optionTable, $data, $write->quoteInto('option_id=?', $intOptionId));
|
51 |
+
}
|
52 |
+
|
53 |
+
if (in_array($optionId, $object->getDefault())) {
|
54 |
+
if ($object->getFrontendInput() == 'multiselect') {
|
55 |
+
$attributeDefaultValue[] = $intOptionId;
|
56 |
+
} else if ($object->getFrontendInput() == 'select') {
|
57 |
+
$attributeDefaultValue = array($intOptionId);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
|
62 |
+
// Default value
|
63 |
+
if (!isset($values[0])) {
|
64 |
+
Mage::throwException(Mage::helper('eav')->__('Default option value is not defined.'));
|
65 |
+
}
|
66 |
+
|
67 |
+
$write->delete($optionValueTable, $write->quoteInto('option_id=?', $intOptionId));
|
68 |
+
foreach ($stores as $store) {
|
69 |
+
if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
|
70 |
+
$data = array(
|
71 |
+
'option_id' => $intOptionId,
|
72 |
+
'store_id' => $store->getId(),
|
73 |
+
'value' => $values[$store->getId()],
|
74 |
+
);
|
75 |
+
$write->insert($optionValueTable, $data);
|
76 |
+
}
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
$write->update($this->getMainTable(), array(
|
81 |
+
'default_value' => implode(',', $attributeDefaultValue)
|
82 |
+
), $write->quoteInto($this->getIdFieldName() . '=?', $object->getId()));
|
83 |
+
}
|
84 |
+
}
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
}
|
app/code/community/VJP/AttributeOptionImage/Model/Eav/Entity/Attribute/Source/Table.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VJP_AttributeOptionImage_Model_Eav_Entity_Attribute_Source_Table extends Mage_Eav_Model_Entity_Attribute_Source_Table
|
4 |
+
{
|
5 |
+
public function getOptionImage($value)
|
6 |
+
{
|
7 |
+
$options = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
8 |
+
->setPositionOrder('asc')
|
9 |
+
->setAttributeFilter($this->getAttribute()->getId())
|
10 |
+
->setStoreFilter($this->getAttribute()->getStoreId())
|
11 |
+
->load()
|
12 |
+
->toArray();
|
13 |
+
foreach ($options['items'] as $item) {
|
14 |
+
if ($item['option_id'] == $value) {
|
15 |
+
return $item['image'];
|
16 |
+
}
|
17 |
+
}
|
18 |
+
return false;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getOptionThumb($value)
|
22 |
+
{
|
23 |
+
$options = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
24 |
+
->setPositionOrder('asc')
|
25 |
+
->setAttributeFilter($this->getAttribute()->getId())
|
26 |
+
->setStoreFilter($this->getAttribute()->getStoreId())
|
27 |
+
->load()
|
28 |
+
->toArray();
|
29 |
+
foreach ($options['items'] as $item) {
|
30 |
+
if ($item['option_id'] == $value) {
|
31 |
+
return $item['thumb'];
|
32 |
+
}
|
33 |
+
}
|
34 |
+
return false;
|
35 |
+
}
|
36 |
+
}
|
app/code/community/VJP/AttributeOptionImage/Model/Eav/Mysql4/Entity/Attribute/Option.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VJP_AttributeOptionImage_Model_Eav_Mysql4_Entity_Attribute_Option extends Mage_Eav_Model_Mysql4_Entity_Attribute_Option
|
4 |
+
{
|
5 |
+
public function getAttributeOptionImages()
|
6 |
+
{
|
7 |
+
$select = $this->getReadConnection()
|
8 |
+
->select()
|
9 |
+
->from($this->getTable('eav/attribute_option'), array('option_id', 'image'));
|
10 |
+
|
11 |
+
return $this->getReadConnection()->fetchPairs($select);
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getAttributeOptionThumbs()
|
15 |
+
{
|
16 |
+
$select = $this->getReadConnection()
|
17 |
+
->select()
|
18 |
+
->from($this->getTable('eav/attribute_option'), array('option_id', 'thumb'));
|
19 |
+
|
20 |
+
return $this->getReadConnection()->fetchPairs($select);
|
21 |
+
}
|
22 |
+
}
|
app/code/community/VJP/AttributeOptionImage/Model/Observer.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class VJP_AttributeOptionImage_Model_Observer
|
4 |
+
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Updates the layout.
|
8 |
+
*
|
9 |
+
* @return void
|
10 |
+
*/
|
11 |
+
public function updateLayout()
|
12 |
+
{
|
13 |
+
$layout = Mage::getSingleton('core/layout');
|
14 |
+
|
15 |
+
$head = $layout->getBlock('head');
|
16 |
+
|
17 |
+
|
18 |
+
$head->setCanLoadExtJs(true)
|
19 |
+
->addJs('mage/adminhtml/variables.js')
|
20 |
+
->addJs('mage/adminhtml/wysiwyg/widget.js')
|
21 |
+
->addJs('lib/flex.js')
|
22 |
+
->addJs('lib/FABridge.js')
|
23 |
+
->addJs('mage/adminhtml/flexuploader.js')
|
24 |
+
->addJs('mage/adminhtml/browser.js')
|
25 |
+
->addJs('prototype/window.js')
|
26 |
+
->addItem('js_css', 'prototype/windows/themes/default.css');
|
27 |
+
|
28 |
+
// Less than 1.7
|
29 |
+
if (version_compare(Mage::getVersion(), '1.7.0.0', '<')) {
|
30 |
+
$head->addItem('js_css', 'prototype/windows/themes/magento.css');
|
31 |
+
} else {
|
32 |
+
$head->addCss('lib/prototype/windows/themes/magento.css');
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
app/code/community/VJP/AttributeOptionImage/controllers/Cms/Wysiwyg/ImagesController.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once 'Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php';
|
4 |
+
|
5 |
+
class VJP_AttributeOptionImage_Cms_Wysiwyg_ImagesController extends Mage_Adminhtml_Cms_Wysiwyg_ImagesController
|
6 |
+
{
|
7 |
+
public function indexAction()
|
8 |
+
{
|
9 |
+
if ($this->getRequest()->getParam('static_urls_allowed')) {
|
10 |
+
$this->_getSession()->setStaticUrlsAllowed(true);
|
11 |
+
}
|
12 |
+
parent::indexAction();
|
13 |
+
}
|
14 |
+
|
15 |
+
public function onInsertAction()
|
16 |
+
{
|
17 |
+
parent::onInsertAction();
|
18 |
+
$this->_getSession()->setStaticUrlsAllowed();
|
19 |
+
}
|
20 |
+
}
|
app/code/community/VJP/AttributeOptionImage/etc/config.xml
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
|
4 |
+
<modules>
|
5 |
+
<VJP_AttributeOptionImage>
|
6 |
+
<version>1.0.1</version>
|
7 |
+
</VJP_AttributeOptionImage>
|
8 |
+
</modules>
|
9 |
+
<global>
|
10 |
+
<resources>
|
11 |
+
<attributeoptionimage_setup>
|
12 |
+
<setup>
|
13 |
+
<module>VJP_AttributeOptionImage</module>
|
14 |
+
</setup>
|
15 |
+
<connection>
|
16 |
+
<use>core_setup</use>
|
17 |
+
</connection>
|
18 |
+
</attributeoptionimage_setup>
|
19 |
+
</resources>
|
20 |
+
|
21 |
+
<models>
|
22 |
+
<vjp_attributeoptionimage>
|
23 |
+
<class>VJP_AttributeOptionImage_Model</class>
|
24 |
+
</vjp_attributeoptionimage>
|
25 |
+
<catalog_resource_eav_mysql4>
|
26 |
+
<rewrite>
|
27 |
+
<attribute>VJP_AttributeOptionImage_Model_Catalog_Resource_Eav_Mysql4_Attribute</attribute>
|
28 |
+
</rewrite>
|
29 |
+
</catalog_resource_eav_mysql4>
|
30 |
+
<eav>
|
31 |
+
<rewrite>
|
32 |
+
<entity_attribute_source_table>VJP_AttributeOptionImage_Model_Eav_Entity_Attribute_Source_Table</entity_attribute_source_table>
|
33 |
+
</rewrite>
|
34 |
+
</eav>
|
35 |
+
<eav_mysql4>
|
36 |
+
<rewrite>
|
37 |
+
<entity_attribute_option>VJP_AttributeOptionImage_Model_Eav_Mysql4_Entity_Attribute_Option</entity_attribute_option>
|
38 |
+
</rewrite>
|
39 |
+
</eav_mysql4>
|
40 |
+
</models>
|
41 |
+
<blocks>
|
42 |
+
<adminhtml>
|
43 |
+
<rewrite>
|
44 |
+
<catalog_product_attribute_edit_tab_options>VJP_AttributeOptionImage_Block_Catalog_Product_Attribute_Edit_Tab_Options</catalog_product_attribute_edit_tab_options>
|
45 |
+
</rewrite>
|
46 |
+
</adminhtml>
|
47 |
+
</blocks>
|
48 |
+
<helpers>
|
49 |
+
<attributeoptionimage>
|
50 |
+
<class>VJP_AttributeOptionImage_Helper</class>
|
51 |
+
</attributeoptionimage>
|
52 |
+
<cms>
|
53 |
+
<rewrite>
|
54 |
+
<wysiwyg_images>VJP_AttributeOptionImage_Helper_Cms_Wysiwyg_Images</wysiwyg_images>
|
55 |
+
</rewrite>
|
56 |
+
</cms>
|
57 |
+
</helpers>
|
58 |
+
</global>
|
59 |
+
|
60 |
+
<admin>
|
61 |
+
<routers>
|
62 |
+
<adminhtml>
|
63 |
+
<args>
|
64 |
+
<modules>
|
65 |
+
<VJP_AttributeOptionImage before="Mage_Adminhtml">VJP_AttributeOptionImage</VJP_AttributeOptionImage>
|
66 |
+
</modules>
|
67 |
+
</args>
|
68 |
+
</adminhtml>
|
69 |
+
</routers>
|
70 |
+
</admin>
|
71 |
+
<adminhtml>
|
72 |
+
<events>
|
73 |
+
<controller_action_layout_render_before_adminhtml_catalog_product_attribute_edit>
|
74 |
+
<observers>
|
75 |
+
<update_layout>
|
76 |
+
<class>vjp_attributeoptionimage/observer</class>
|
77 |
+
<method>updateLayout</method>
|
78 |
+
</update_layout>
|
79 |
+
</observers>
|
80 |
+
</controller_action_layout_render_before_adminhtml_catalog_product_attribute_edit>
|
81 |
+
</events>
|
82 |
+
</adminhtml>
|
83 |
+
<frontend>
|
84 |
+
<layout>
|
85 |
+
<updates>
|
86 |
+
<attributeoptionimage>
|
87 |
+
<file>attributeoptionimage.xml</file>
|
88 |
+
</attributeoptionimage>
|
89 |
+
</updates>
|
90 |
+
</layout>
|
91 |
+
</frontend>
|
92 |
+
|
93 |
+
</config>
|
app/code/community/VJP/AttributeOptionImage/sql/vjp_attributeoptionimage_setup/mysql4-install-1.0.0.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
5 |
+
|
6 |
+
$tableOption = $this->getTable('eav_attribute_option');
|
7 |
+
$installer->startSetup();
|
8 |
+
|
9 |
+
$installer->run("
|
10 |
+
ALTER TABLE `{$tableOption}`
|
11 |
+
ADD `image` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
|
12 |
+
");
|
13 |
+
|
14 |
+
$installer->endSetup();
|
app/code/community/VJP/AttributeOptionImage/sql/vjp_attributeoptionimage_setup/mysql4-upgrade-1.0.0-1.0.1.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
5 |
+
|
6 |
+
$tableOption = $this->getTable('eav_attribute_option');
|
7 |
+
$installer->startSetup();
|
8 |
+
|
9 |
+
$installer->run("
|
10 |
+
ALTER TABLE `{$tableOption}`
|
11 |
+
ADD `thumb` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
|
12 |
+
");
|
13 |
+
|
14 |
+
$installer->endSetup();
|
app/code/community/VJP/DirectCheckout/Block/DirectCheckout.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class VJP_DirectCheckout_Block_DirectCheckout extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
|
5 |
+
// necessary methods
|
6 |
+
}
|
7 |
+
?>
|
app/code/community/VJP/DirectCheckout/controllers/Catalog/ProductController.php
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
# Controllers are not autoloaded so we will have to do it manually:
|
3 |
+
require_once 'Mage/Catalog/controllers/ProductController.php';
|
4 |
+
|
5 |
+
class VJP_DirectCheckout_Catalog_ProductController extends Mage_Catalog_ProductController
|
6 |
+
{
|
7 |
+
public function viewAction()
|
8 |
+
{
|
9 |
+
echo 'vishal';
|
10 |
+
// Get initial data from request
|
11 |
+
$categoryId = (int) $this->getRequest()->getParam('category', false);
|
12 |
+
$productId = (int) $this->getRequest()->getParam('id');
|
13 |
+
$specifyOptions = $this->getRequest()->getParam('options');
|
14 |
+
|
15 |
+
// Prepare helper and params
|
16 |
+
$viewHelper = Mage::helper('catalog/product_view');
|
17 |
+
|
18 |
+
$params = new Varien_Object();
|
19 |
+
$params->setCategoryId($categoryId);
|
20 |
+
$params->setSpecifyOptions($specifyOptions);
|
21 |
+
|
22 |
+
// Render page
|
23 |
+
try {
|
24 |
+
$viewHelper->prepareAndRender($productId, $this, $params);
|
25 |
+
} catch (Exception $e) {
|
26 |
+
if ($e->getCode() == $viewHelper->ERR_NO_PRODUCT_LOADED) {
|
27 |
+
if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) {
|
28 |
+
$this->_redirect('');
|
29 |
+
} elseif (!$this->getResponse()->isRedirect()) {
|
30 |
+
$this->_forward('noRoute');
|
31 |
+
}
|
32 |
+
} else {
|
33 |
+
Mage::logException($e);
|
34 |
+
$this->_forward('noRoute');
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
?>
|
app/code/community/VJP/DirectCheckout/controllers/Checkout/CartController.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
# Controllers are not autoloaded so we will have to do it manually:
|
3 |
+
require_once 'Mage/Checkout/controllers/CartController.php';
|
4 |
+
|
5 |
+
class VJP_DirectCheckout_Checkout_CartController extends Mage_Checkout_CartController
|
6 |
+
{
|
7 |
+
|
8 |
+
public function addcheckoutAction()
|
9 |
+
{
|
10 |
+
$cart = $this->_getCart();
|
11 |
+
$params = $this->getRequest()->getParams();
|
12 |
+
try {
|
13 |
+
if (isset($params['qty'])) {
|
14 |
+
$filter = new Zend_Filter_LocalizedToNormalized(
|
15 |
+
array('locale' => Mage::app()->getLocale()->getLocaleCode())
|
16 |
+
);
|
17 |
+
$params['qty'] = $filter->filter($params['qty']);
|
18 |
+
}
|
19 |
+
|
20 |
+
$product = $this->_initProduct();
|
21 |
+
$related = $this->getRequest()->getParam('related_product');
|
22 |
+
|
23 |
+
if (!$product) {
|
24 |
+
$this->_goBack();
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
$cart->addProduct($product, $params);
|
29 |
+
if (!empty($related)) {
|
30 |
+
$cart->addProductsByIds(explode(',', $related));
|
31 |
+
}
|
32 |
+
|
33 |
+
$cart->save();
|
34 |
+
|
35 |
+
$this->_getSession()->setCartWasUpdated(true);
|
36 |
+
|
37 |
+
Mage::dispatchEvent('checkout_cart_add_product_complete',
|
38 |
+
array('product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse())
|
39 |
+
);
|
40 |
+
|
41 |
+
if (!$this->_getSession()->getNoCartRedirect(true)) {
|
42 |
+
if (!$cart->getQuote()->getHasError()){
|
43 |
+
$message = $this->__('%s was added to your shopping cart.', Mage::helper('core')->htmlEscape($product->getName()));
|
44 |
+
$this->_getSession()->addSuccess($message);
|
45 |
+
}
|
46 |
+
// if(Mage::getUrl('checkout/cart/') == $_SERVER['HTTP_REFERER']){
|
47 |
+
// $this->_goBack();
|
48 |
+
$this->_redirect('checkout/onepage');
|
49 |
+
|
50 |
+
}
|
51 |
+
} catch (Mage_Core_Exception $e) {
|
52 |
+
if ($this->_getSession()->getUseNotice(true)) {
|
53 |
+
$this->_getSession()->addNotice($e->getMessage());
|
54 |
+
} else {
|
55 |
+
$messages = array_unique(explode("\n", $e->getMessage()));
|
56 |
+
foreach ($messages as $message) {
|
57 |
+
$this->_getSession()->addError($message);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
$url = $this->_getSession()->getRedirectUrl(true);
|
62 |
+
if ($url) {
|
63 |
+
$this->getResponse()->setRedirect($url);
|
64 |
+
} else {
|
65 |
+
$this->_redirectReferer(Mage::helper('checkout/cart')->getCartUrl());
|
66 |
+
}
|
67 |
+
} catch (Exception $e) {
|
68 |
+
$this->_getSession()->addException($e, $this->__('Cannot add the item to shopping cart.'));
|
69 |
+
Mage::logException($e);
|
70 |
+
$this->_goBack();
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
app/code/community/VJP/DirectCheckout/etc/config.xml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<global>
|
4 |
+
<modules>
|
5 |
+
<vjp_directcheckout>
|
6 |
+
<version>1.0.0</version>
|
7 |
+
</vjp_directcheckout>
|
8 |
+
</modules>
|
9 |
+
<blocks>
|
10 |
+
<directcheckout>
|
11 |
+
<rewrite>
|
12 |
+
<directcheckout>VJP_DirectCheckout_Block_DirectCheckout</directcheckout>
|
13 |
+
</rewrite>
|
14 |
+
</directcheckout>
|
15 |
+
|
16 |
+
<!-- <catalog>
|
17 |
+
<rewrite>
|
18 |
+
<directcheckout>VJP_DirectCheckout_Block_Catalog</directcheckout>
|
19 |
+
</rewrite>
|
20 |
+
</catalog>
|
21 |
+
--> </blocks>
|
22 |
+
<rewrite>
|
23 |
+
<vjp_directcheckout_checkout_cart>
|
24 |
+
<from><![CDATA[#^/checkout/cart/#]]></from>
|
25 |
+
<to>/directcheckout/checkout_cart/</to>
|
26 |
+
</vjp_directcheckout_checkout_cart>
|
27 |
+
</rewrite>
|
28 |
+
</global>
|
29 |
+
<frontend>
|
30 |
+
<routers>
|
31 |
+
<directcheckout>
|
32 |
+
<use>standard</use>
|
33 |
+
<args>
|
34 |
+
<module>VJP_DirectCheckout</module>
|
35 |
+
<frontName>directcheckout</frontName>
|
36 |
+
</args>
|
37 |
+
</directcheckout>
|
38 |
+
</routers>
|
39 |
+
<layout>
|
40 |
+
<updates>
|
41 |
+
<directcheckout>
|
42 |
+
<file>directcheckout.xml</file>
|
43 |
+
</directcheckout>
|
44 |
+
</updates>
|
45 |
+
</layout>
|
46 |
+
</frontend>
|
47 |
+
</config>
|
app/design/frontend/default/default/layout/directcheckout.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="1.0.0">
|
3 |
+
<catalog_product_view>
|
4 |
+
<reference name="product.info.addtocart">
|
5 |
+
<block type="directcheckout/directcheckout" name="directcheckout" after="addtocart" template="directcheckout/directcheckout.phtml"/>
|
6 |
+
</reference>
|
7 |
+
</catalog_product_view>
|
8 |
+
<vjp_directcheckout_checkout_cart_index>
|
9 |
+
<update handle="checkout_cart_index"/>
|
10 |
+
</vjp_directcheckout_checkout_cart_index>
|
11 |
+
|
12 |
+
</layout>
|
app/design/frontend/default/default/template/directcheckout/directcheckout.phtml
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$_product = Mage::registry('current_product');
|
3 |
+
?>
|
4 |
+
<button type="button" class="button" style="margin:0 5px;" name="add to checkout" onclick="return addtocheckout(<?php echo $_product->getId(); ?>)" value="DIRECT CHECKOUT" title="DIRECT CHECKOUT"><span>Direct Checkout</span></button>
|
5 |
+
|
6 |
+
<script type="text/javascript">
|
7 |
+
function addtocheckout(id)
|
8 |
+
{
|
9 |
+
var myform = document.getElementById('product_addtocart_form');
|
10 |
+
var qty = document.getElementById('qty').value;
|
11 |
+
myform.action = "<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); ?>checkout/cart/addcheckout/product/"+ id +"/qty/"+qty+"/";
|
12 |
+
myform.submit();
|
13 |
+
}
|
14 |
+
</script>
|
app/etc/modules/VJP_DirectCheckout.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<VJP_DirectCheckout>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
</VJP_DirectCheckout>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>VJP_DirectCheckout</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Direct Checkout</summary>
|
10 |
+
<description>This Module will give ability to show Direct Checkout button on product detail page near Add to cart button which add product to cart with quantity given in quantity box and will redirect to checkout page directly.</description>
|
11 |
+
<notes>Direct Checkout</notes>
|
12 |
+
<authors><author><name>vishal4671</name><user>vishal4671</user><email>vishal6714@gmail.com</email></author></authors>
|
13 |
+
<date>2013-04-03</date>
|
14 |
+
<time>12:19:57</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="VJP"><dir name="AttributeOptionImage"><dir name="Block"><dir name="Catalog"><dir name="Product"><dir name="Attribute"><dir name="Edit"><dir name="Tab"><file name="Options.php" hash="f3f3e759e815a65ba78c5d55a8bed4bf"/></dir></dir></dir><dir name="View"><file name="Attributes.php" hash="0fcbfb53770d9cbee1f4c52f7ede4fd5"/><file name="view.phtml" hash="b4af85ac8cd26c8c1cc5884d0a461010"/></dir></dir></dir></dir><dir name="Helper"><dir name="Cms"><dir name="Wysiwyg"><file name="Images.php" hash="d6bdf01cbc753bc43a4ef06e65ebca4c"/></dir></dir><file name="Data.php" hash="7003f64dc73414c636cb9574dae6ced3"/></dir><dir name="Model"><dir name="Catalog"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Attribute.php" hash="31076992ae4f8da3f4a699233fd3d869"/></dir></dir></dir></dir><dir name="Eav"><dir name="Entity"><dir name="Attribute"><dir name="Source"><file name="Table.php" hash="83e7f0a50c572c23a0b403501eceed2d"/></dir></dir></dir><dir name="Mysql4"><dir name="Entity"><dir name="Attribute"><file name="Option.php" hash="6d0f5a832bb0d785f88ce9128e77c377"/></dir></dir></dir></dir><file name="Observer.php" hash="e3e643644e407d90139a3f108c5d73b9"/></dir><dir name="controllers"><dir name="Cms"><dir name="Wysiwyg"><file name="ImagesController.php" hash="98848d4e999f2c9710875c2cb9acb7ce"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="03de76671386b1550d798543956e8b51"/></dir><dir name="sql"><dir name="vjp_attributeoptionimage_setup"><file name="mysql4-install-1.0.0.php" hash="287548e37fa33bfd3c40e1c3145d9be9"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="5b867c904b5ee38d9e7cfdb4c629cee6"/></dir></dir></dir><dir name="DirectCheckout"><dir name="Block"><file name="DirectCheckout.php" hash="1e25022332a64e348707fdd9c400bad0"/></dir><dir name="controllers"><dir name="Catalog"><file name="ProductController.php" hash="63d7aee89e58f002918862441d6d57fc"/></dir><dir name="Checkout"><file name="CartController.php" hash="fe980450441a62c744414c6ef0d6f0b4"/></dir></dir><dir name="etc"><file name="config.xml" hash="8b4d2310c25e9b621522da1ff6ca90c2"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="directcheckout.xml" hash="fb012860d6a39fa1c2005e294223cf8c"/></dir><dir name="template"><dir name="directcheckout"><file name="directcheckout.phtml" hash="3228a9c4fca73a6d5f14849268aa45a4"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="VJP_DirectCheckout.xml" hash="2f2f9068450f99d574e1802f9389ba4d"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>5.4.12</max></php></required></dependencies>
|
18 |
+
</package>
|