<?php
class CJM_ColorSelectorPlus_Helper_Data extends Mage_Core_Helper_Abstract
{
public function getImageSizes()
{
$theSizes = array();
$b = str_replace(" ", "", Mage::getStoreConfig('color_selector_plus/templatesettings/prodimgsize', Mage::app()->getStore()));
$b = !$b ? '265x265' : strtolower($b);
$exploder = preg_match("/x/i", $b) ? $b : $b.'x'.$b;
$sizes = explode("x", $exploder);
$theSizes['base']['width'] = $sizes[0];
$theSizes['base']['height'] = $sizes[1];
$m = str_replace(" ", "", Mage::getStoreConfig('color_selector_plus/templatesettings/moreimgsize', Mage::app()->getStore()));
$m = !$m ? '56x56' : strtolower($m);
$exploder = preg_match("/x/i", $m) ? $m : $m.'x'.$m;
$sizes = explode("x", $exploder);
$theSizes['more']['width'] = $sizes[0];
$theSizes['more']['height'] = $sizes[1];
$l = str_replace(" ", "", Mage::getStoreConfig('color_selector_plus/templatesettings/listimgsize', Mage::app()->getStore()));
$l = !$l ? '135x135' : strtolower($l);
$exploder = preg_match("/x/i", $l) ? $l : $l.'x'.$l;
$sizes = explode("x", $exploder);
$theSizes['list']['width'] = $sizes[0];
$theSizes['list']['height'] = $sizes[1];
return $theSizes;
}
public function getImageName($image_src)
{
$parts = explode("/", $image_src);
$theName = $parts[count($parts) - 1];
$theName_parts = explode(".", $theName);
$imageName = $theName_parts[0];
return $imageName;
}
public function getUsesSwatchAttribs($_product)
{
$swatch_attributes = Mage::helper('colorselectorplus')->getSwatchAttributes();
$confAttributes = $_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product);
foreach($confAttributes as $confAttribute):
$thecode = $confAttribute["attribute_code"];
if(in_array($thecode, $swatch_attributes)) {
return 'yes';}
endforeach;
return 'no';
}
public function getConfigQueryString($_options, $confAttributes)
{
$swatch_attributes = Mage::helper('colorselectorplus')->getSwatchAttributes();
$query = array();
foreach($confAttributes as $confAttribute) :
if(in_array($confAttribute['attribute_code'], $swatch_attributes))
{
$attributeCode = $confAttribute['attribute_code'];
$attributeName = $confAttribute['label'];
foreach($_options as $_option) :
if($attributeName == $_option['label']) {
$attributeoption = $_option['value']; }
endforeach;
if($attributeoption) {
$query[$attributeCode] = $attributeoption; }
}
endforeach;
return '?'.http_build_query($query);
}
public function getSortedByPosition($array)
{
$new = '';
$new1 = '';
foreach ($array as $k=>$na)
$new[$k] = serialize($na);
$uniq = array_unique($new);
foreach($uniq as $k=>$ser)
$new1[$k] = unserialize($ser);
if(isset($new1)){
return $new1; }
else {
return '';}
}
public function getAssociatedOptions($product, $att)
{
$swatch_attributes = Mage::helper('colorselectorplus')->getSwatchAttributes();
$confAttributes = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
$availattribs = array();
$thecode = '';
$html = '';
foreach ($confAttributes as $confAttribute) {
$thecode = $confAttribute["attribute_code"];
if(in_array($thecode, $swatch_attributes))
{
$attributeCode = $confAttribute['attribute_code'];
$attributeName = $confAttribute['label'];
$options = $confAttribute["values"];
foreach($options as $option) {
$string = $option["label"];
$label = trim(substr($string, 0, strpos("$string#", "#")));
$optvalue = $option["value_index"];
$availattribs['value'][] = $optvalue;
$availattribs['label'][] = $label;;
}
}
}
if($availattribs) {
$count = count($availattribs['value']);
} else {
$count = 0; }
if($count < 1) {
$html .= '<select class="'.$att.'" id="'.$att.'__value_id__" name="'.$att.'[__value_id__]" disabled="disabled" style="width:100px;">'; }
else {
$html .= '<select class="'.$att.'" id="'.$att.'__value_id__" name="'.$att.'[__value_id__]" style="width:100px;">';
if($att == 'cjm_moreviews') {
$html .= '<option value="">';
$html .= Mage::helper('colorselectorplus')->__('*Always Visible*');
$html .= '</option>';
$html .= '<option value="none">';
$html .= Mage::helper('colorselectorplus')->__('*None*');
$html .= '</option>'; }
else {
$html .= '<option value=""> </option>'; }
for($s = 0; $s < $count; $s++) {
$html .= '<option value="'.$availattribs['value'][$s].'">'.$availattribs['label'][$s].'</option>'; }
$html .= '</select><br />';
}
return $html;
}
public function getMoreViews($_product)
{
$html = '';
$html_first = '';
$onloads = '';
$defaults = '';
$defaultmoreviews = 0;
$product_base = Mage::helper('colorselectorplus')->decodeImages($_product);
$theSizes = Mage::helper('colorselectorplus')->getImageSizes();
if($product_base):
$swatch_attributes = Mage::helper('colorselectorplus')->getSwatchAttributes();
$confAttributes = $_product->getTypeInstance(true)->getConfigurableAttributesAsArray($_product);
$images = $product_base['image'];
foreach($images as $key => $image):
if($product_base['defaultimg'][$key] == 1 && $product_base['morev'][$key] != ''):
$defaultmoreviews = 1;
$product_image = $product_base['image'][$key];
$product_thumb = $product_base['thumb'][$key];
$product_label = $product_base['label'][$key];
$onloads .= '<li class="onload-moreviews"><a href="'.$product_image.'" onclick="$(\'image\').src = this.href; return false;"><img src="'.$product_thumb.'" width="'.$theSizes['more']['width'].'" height="'.$theSizes['more']['height'].'" alt="'.$product_label.'" title="'.$product_label.'" /></a></li>';
elseif($product_base['morev'][$key] == ''):
$defaultmoreviews = 1;
$product_image = $product_base['image'][$key];
$product_thumb = $product_base['thumb'][$key];
$product_label = $product_base['label'][$key];
$defaults .= '<li class="default-moreviews"><a href="'.$product_image.'" onclick="$(\'image\').src = this.href; return false;"><img src="'.$product_thumb.'" width="'.$theSizes['more']['width'].'" height="'.$theSizes['more']['height'].'" alt="'.$product_label.'" title="'.$product_label.'" /></a></li>';
endif;
endforeach;
if($defaultmoreviews == 1) {
$html_first = '<h2 id="moreviews-title">'.Mage::helper('colorselectorplus')->__('More Views').'</h2><ul id="ul-moreviews">'; }
else {
$html_first = '<h2 id="moreviews-title" style="display:none;">'.Mage::helper('colorselectorplus')->__('More Views').'</h2><ul id="ul-moreviews">'; }
$html = $html_first .= $html;
if($onloads){ $html .= $onloads; }
if($defaults){ $html .= $defaults; }
foreach($confAttributes as $confAttribute):
$thecode = $confAttribute["attribute_code"];
if(in_array($thecode, $swatch_attributes)):
$options = $confAttribute["values"];
foreach($options as $option):
$value = $option['value_index'];
foreach($images as $key => $image):
if($product_base['morev'][$key] == $value):
$product_image = $product_base['image'][$key];
$product_thumb = $product_base['thumb'][$key];
$product_label = $product_base['label'][$key];
$html .= '<li class="moreview'.$value.'" style="display:none;"><a href="'.$product_image.'" onclick="$(\'image\').src = this.href; return false;"><img src="'.$product_thumb.'" width="'.$theSizes['more']['width'].'" height="'.$theSizes['more']['height'].'" alt="'.$product_label.'" title="'.$product_label.'" /></a></li>';
endif;
endforeach;
endforeach;
endif;
endforeach;
$html .= '</ul>';
return $html;
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
PreselectColors Swatches(产品颜色切换).zip (80个子文件)
PreselectColors+Swatches(产品颜色切换)
PreselectColors+Swatches
8.jpg 46KB
2.jpg 30KB
1.jpg 71KB
6.jpg 46KB
3.jpg 32KB
5.jpg 40KB
PreselectColors+Swatches
media
colorselectorplus
swatches
empty.jpg 2KB
skin
adminhtml
default
default
colorselectorplus
css
colorselectorplus.css 933B
images
colorselectorplus_section.png 3KB
cjm_section.png 2KB
frontend
default
default
css
swatches.css 4KB
images
loading.gif 673B
js
cjm
colorselectorplus
zoom.js 519B
colorselected.js 15KB
listswitch.js 397B
jquery.jqzoom-core-pack.js 9KB
product.js 42KB
jquery-1.6.4.min.js 90KB
app
design
adminhtml
default
default
layout
colorselectorplus.xml 952B
template
colorselectorplus
catalog
product
edit
super
config.phtml 8KB
swatches.phtml 5KB
frontend
default
default
layout
colorselectorplus.xml 4KB
template
colorselectorplus
listswatches.phtml 503B
catalog
product
view
type
options
configurable.phtml 3KB
media.phtml 8KB
list.phtml 8KB
filter.phtml 214B
checkout
cart
item
default.phtml 18KB
locale
en_US
CJM_ColorSelectorPlus.csv 4KB
code
local
CJM
All
Model
Observer.php 288B
Feed.php 2KB
etc
config.xml 885B
ColorSelectorPlus
Model
Attributes.php 2KB
Catalog
Product
Attribute
Backend
Media.php 10KB
Url.php 541B
Resource
Product
Attribute
Backend
Media.php 3KB
Observer.php 2KB
Position.php 502B
Hideffect.php 322B
Mysql4
Setup.php 94B
Speed.php 311B
Truefalse.php 317B
Showeffect.php 321B
Swatches.php 549B
Type.php 519B
Toshow.php 1KB
Helper
Catalog
Product.php 2KB
Data.php 26KB
controllers
Override
Admin
Catalog
ProductController.php 3KB
Product
AttributeController.php 2KB
Catalog
ProductController.php 3KB
sql
colorselectorplus_setup
mysql4-upgrade-3.2.4-3.2.5.php 1KB
mysql4-upgrade-3.2.5-3.5.0.php 404B
mysql4-install-3.2.4.php 2KB
Block
System
Config
About.php 2KB
Info.php 2KB
Swatches.php 738B
Catalog
Product
View
Type
Configurable.php 856B
Layer
Filter
Attribute.php 2KB
Listswatch.php 6KB
Adminhtml
Catalog
Product
Attribute
Edit
Tabs.php 900B
Form.php 502B
Helper
Form
Gallery
Content.php 812B
Edit
Tab
Super
Config.php 1KB
Swatches.php 227B
CatalogSearch
Layer
Filter
Attribute.php 2KB
etc
adminhtml.xml 512B
config.xml 7KB
system.xml 24KB
blocks
Adminhtml
catalog
product
helper
gallery.phtml 12KB
etc
modules
CJM_All.xml 144B
CJM_ColorSelectorPlus.xml 185B
EULA.rtf 4KB
description.rtf 4KB
4.jpg 74KB
Chart.jpg 51KB
9.jpg 98KB
7.jpg 68KB
~$README.rtf 162B
README.rtf 3KB
共 80 条
- 1
资源评论
- zhangyuyu2523349732015-08-07不错,网站正好缺少这个功能。。。
- 围脖小生2015-06-21公司项目需要用,不过后面用了自带的修改成功了。
- molican2015-03-17好用,正缺少这个功能
- qq_306111952015-10-02不错的哈, 终于可以用了
- jgg454502016-05-061.9版本好像不能用,配置那边出现404
帽帽好多小钱钱
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功