0

oldprice文字列の値が文字列以上の場合、文字列を非表示にする必要がありpriceます。

文字列の正しい構文は何oldpriceですか?

 // Save product data into result array
     $result['products'][] = array(
     'id' => $_product->getId(),
     'in_stock' => (bool)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getIsInStock(),
     'url' => str_replace('/index.php', null, $result['shop_data']['url']) . $_product->getUrlKey() . $helper->getProductUrlSuffix(),
     'price' => $_product->getFinalPrice(),
     'oldprice' => $_product->getPrice(),
     'currencyId' => $currencyCode,
     'categoryId' => $_category->getId(),
     'picture' => $picUrl,
     'name' => $_product->getName(),
     'vendor' => trim($_product->getAttributeText('manufacturer')),
     'model' => $_product->getSku(),
     'description' => trim(strip_tags($_product->getShortDescription())),
     'local_delivery_cost' => $priceship[0],    
     'market_category' => trim($_product->getAttributeText('market_category')),
     'country_of_origin' => trim($_product->getAttributeText('country_of_manufacture')),
     'local_delivery_cost' => 500,
     'sales_notes' => '100% предоплата',
 );
4

2 に答える 2

0

製品データを配列に保存する前に、if 条件を記述します。

<?php

   $oldprice = null;
   $finalprice = $_product->getFinalPrice();
   $price = $_product->getPrice();
   if($price>=$finalprice)
   {
     $oldprice =  $_product->getPrice();
   }

?>

そして、配列を初期化します

$result['products'][] = array(
     'id' => $_product->getId(),
     'in_stock' => (bool)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getIsInStock(),
     'url' => str_replace('/index.php', null, $result['shop_data']['url']) . $_product->getUrlKey() . $helper->getProductUrlSuffix(),
     'price' => $finalprice,
     'oldprice' => $price,
     'currencyId' => $currencyCode,
     'categoryId' => $_category->getId(),
     'picture' => $picUrl,
     'name' => $_product->getName(),
     'vendor' => trim($_product->getAttributeText('manufacturer')),
     'model' => $_product->getSku(),
     'description' => trim(strip_tags($_product->getShortDescription())),
     'local_delivery_cost' => $priceship[0],    
     'market_category' => trim($_product->getAttributeText('market_category')),
     'country_of_origin' => trim($_product->getAttributeText('country_of_manufacture')),
     'local_delivery_cost' => 500,
     'sales_notes' => '100% предоплата',
 );
于 2015-11-02T11:45:54.047 に答える