我想添加一个带有以下选项的单选按钮
显示产品
> United States
> International
> Both
Run Code Online (Sandbox Code Playgroud)
选择后,产品将在前端显示使用IP检测的相应客户
我谷歌它,我发现了一个插件
但它与Magento ver不兼容.1.5.0.1.请帮忙.谢谢
我在首页上有一个自定义块加载产品,它通过以下方式加载了四个具有自定义产品图片属性集的最新产品:
$_helper = $this->helper('catalog/output');
$_productCollection = Mage::getModel("catalog/product")->getCollection();
$_productCollection->addAttributeToSelect('*');
$_productCollection->addAttributeToFilter("image_feature_front_right", array("notnull" => 1));
$_productCollection->addAttributeToFilter("image_feature_front_right", array("neq" => 'no_selection'));
$_productCollection->addAttributeToSort('updated_at', 'DESC');
$_productCollection->setPageSize(4);
Run Code Online (Sandbox Code Playgroud)
我想要做的是抓住image_feature_front_right后端设置的标签,但是无法这样做.这是我在前端显示产品的代码:
<?php foreach($_productCollection as $_product) : ?>
<div class="fll frontSale">
<div class="productImageWrap">
<img src="<?php echo $this->helper('catalog/image')->init($_product, 'image_feature_front_right')->directResize(230,315,4) ?>" />
</div>
<div class="salesItemInfo">
<a href="<?php echo $this->getUrl($_product->getUrlPath()) ?>"><p class="caps"><?php echo $this->htmlEscape($_product->getName());?></p></a>
<p class="nocaps"><?php echo $this->getImageLabel($_product, 'image_feature_front_right') ?></p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我读到这$this->getImageLabel($_product, 'image_feature_front_right')是做到这一点的方法,但什么也没有产生.我究竟做错了什么?
谢谢!
TRE
我尝试了几个我可以在谷歌找到的想法,但几天没有人为我工作.最后,我发现了一种在自定义扩展中显示magento中捆绑产品的"最小可能价格"和"最大可能价格"的方法:
$_product_id = YOUR_BUNDLE_PRODUCT_ID;
// highest possible price for this bundle product
$return_type = 'max'; // because I used this in a helper method
// lowest possible price for this bundle product
// $return_type = 'min';
$model_catalog_product = Mage::getModel('catalog/product'); // getting product model
$_product = $model_catalog_product->load( $_product_id );
$TypeInstance = $_product->getTypeInstance(true);
$Selections = $TypeInstance->getSelectionsCollection($OptionIds, $_product );
$Options = $TypeInstance->getOptionsByIds($OptionIds, $_product);
$bundleOptions = $Options->appendSelections($Selections, true);
$minmax_pricevalue = 0; // to sum them up from 0
foreach ($bundleOptions as $bundleOption) {
if …Run Code Online (Sandbox Code Playgroud) public static void main(String[]args){
int A[]={2,4,6,9,5,4,5,7,12,15,21,32,45,5,6,7,12};
int multi= 1;
for (int i=0; i<A.length; i++) {
multi *= A[i];
}
System.out.println("The product of the numbers in the array is " + multi );
//I keep getting a negative value but when I shorten the array
//to a few numbers I don't have any problems.
}
Run Code Online (Sandbox Code Playgroud) 在我的更新XML中,我有:
<reference name="content">
<remove name="product.info" />
<block type="catalog/product_view" template="catalog/product/imageview.phtml">
<action method="setData"><name>variable</name><value>3</value></action>
</block>
</reference>
Run Code Online (Sandbox Code Playgroud)
我创建了imageview.phtml并正确加载.在此模板中,我转储以下内容:
var_dump($this->getVariable());
Run Code Online (Sandbox Code Playgroud)
我的预期结果是:3
但结果是:NULL
我错过了什么?
我使用REST来调用Magento产品列表,但它只显示了10个产品而不是所有产品.
任何人都可以指导,因为可能会出现这个问题?
这是我用来调用其余api的代码: -
$url = 'magentohost url';
$callbackUrl = $url . "oauth_admin.php";
$temporaryCredentialsRequestUrl = $url . "oauth/initiate?oauth_callback=" . urlencode($callbackUrl);
$adminAuthorizationUrl = $url . 'admin/oauth_authorize';
$accessTokenRequestUrl = $url . 'oauth/token';
$apiUrl = $url . 'api/rest';
$consumerKey = 'consumer_key';
$consumerSecret = 'consumer_secret';
$token = 'token';
$secret = 'token_secret';
try {
$oauthClient = new OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
$oauthClient->setToken($token, $secret);
$resourceUrl = "$apiUrl/products";
$oauthClient->fetch($resourceUrl, array(), 'GET', array('Content-Type' => 'application/json', 'Accept' => 'application/json'));
$productsList = json_decode($oauthClient->getLastResponse());
echo '<pre>';
print_r($productsList);
}
catch(Exception $e) { …Run Code Online (Sandbox Code Playgroud) 我一直在寻找许多博客和论坛,但这似乎还没有回答.所以我试图找到一种如何按属性过滤产品的方法.我正在使用ajax来提取数据并附加它.问题是,使循环的查询取决于什么属性.
例.
产品A有颜色:蓝色,红色,绿色,品牌有:BrandA,BrandB
产品B有颜色:粉红色,红色,黑色.
我想要的是在不使用任何插件的情况下,在单个查询中获得具有Color [红色和绿色]属性和Brand [BrandA]的所有产品.这里我的代码在我的functions.php中
function advanced_search(){
$html = "";
$args = array( 'post_type' => 'product','product_cat' => 'yarn');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ){
$loop->the_post();
ob_start();
get_template_part( 'templates/part', 'search-result' );
$html = ob_get_contents();
ob_end_clean();
}
wp_send_json(array( "product_id" => $product_id , "html" => $html ));
}
add_action('wp_ajax_get_advanced_search', 'advanced_search');
add_action('wp_ajax_nopriv_get_advanced_search', 'advanced_search');
Run Code Online (Sandbox Code Playgroud)
我不知道我应该在哪里将产品属性放在我的查询中.我希望有人能找到答案.非常感谢你.
我正在运行WooCommerce版本2.5.5。以下代码行似乎并未更改具有变化项的产品页面上“添加到购物车”按钮上的文本:
add_filter('variable_add_to_cart_text', 'my_custom_cart_button_text');
function my_custom_cart_button_text() {
return __('Buy Now', 'woocommerce');
}
Run Code Online (Sandbox Code Playgroud)
您会碰巧知道我在想什么吗?
我正在使用CI框架,我正在尝试创建一个foreach循环,以便显示我站点的所有产品.
这是我的控制器文件:
class AlleCadeausController extends CI_Controller {
public function index()
{
$this->load->model('allecadeaus_model');
$data['cadeaus'] = $this->allecadeaus_model->get_cadeaus();
$this->load->view('allecadeaus');
}
Run Code Online (Sandbox Code Playgroud)
这是我的模型文件:
<?php
class Allecadeaus_model extends CI_Model {
public function __construct()
{
parent::__construct();
}
public function get_cadeaus()
{
$query = $this->db->query('SELECT * FROM products');
$result = $query->result_array();
return $result;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的看法:
<?php
foreach ($cadeaus as $cadeau)
{
echo $cadeau->product_naam;
}
?>
Run Code Online (Sandbox Code Playgroud)
错误是:
遇到PHP错误
严重性:注意
消息:未定义的变量:cadeaus
文件名:views/allecadeaus.php
行号:3
回溯:
文件:/home/ubuntu/workspace/application/views/allecadeaus.php行:3功能:_error_handler
文件:/home/ubuntu/workspace/application/controllers/AlleCadeausController.php行:11功能:查看
文件:/home/ubuntu/workspace/index.php行:315功能:require_once
我的表名是 products
我已经完成了这些术语的所有正式定义.但是,我仍然很难理解他们.我是hybris的初学者.那么有人可以解释这些概念尽可能简单吗?