本文整理汇总了PHP中Ess_M2ePro_Model_Listing_Product::getVariations方法的典型用法代码示例。如果您正苦于以下问题:PHP Ess_M2ePro_Model_Listing_Product::getVariations方法的具体用法?PHP Ess_M2ePro_Model_Listing_Product::getVariations怎么用?PHP Ess_M2ePro_Model_Listing_Product::getVariations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ess_M2ePro_Model_Listing_Product
的用法示例。
在下文中一共展示了Ess_M2ePro_Model_Listing_Product::getVariations方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isAddedNewVariationsAttributes
public function isAddedNewVariationsAttributes(Ess_M2ePro_Model_Listing_Product $listingProduct)
{
if ($listingProduct->getMagentoProduct()->isProductWithoutVariations()) {
return false;
}
// Prepare Magento Variations
//-----------------------------
$tempMagentoVariations = $listingProduct->getMagentoProduct()->getProductVariations();
$tempMagentoVariations = $this->validateChannelConditions($tempMagentoVariations, false);
//-----------------------------
// Get Variations
//-----------------------------
$magentoVariations = $this->prepareMagentoVariations($tempMagentoVariations);
$currentVariations = $this->prepareCurrentVariations($listingProduct->getVariations(true));
//-----------------------------
if (!isset($magentoVariations[0]) && !isset($currentVariations[0])) {
return false;
}
if (!isset($magentoVariations[0]) || !isset($currentVariations[0])) {
return true;
}
if (count($magentoVariations[0]['options']) != count($currentVariations[0]['options'])) {
return true;
}
return false;
}
示例2: inspectAndFixProductOptionsIds
private function inspectAndFixProductOptionsIds(Ess_M2ePro_Model_Listing_Product $listingProduct, $magentoVariations)
{
/** @var Ess_M2ePro_Model_Listing_Product_Variation[] $listingProductVariations */
$listingProductVariations = $listingProduct->getVariations(true);
if (empty($listingProductVariations)) {
return;
}
foreach ($listingProductVariations as $listingProductVariation) {
$listingProductVariationOptions = $listingProductVariation->getOptions();
foreach ($magentoVariations as $magentoVariation) {
$magentoVariationOptions = $magentoVariation['options'];
if (!$this->isEqualVariations($magentoVariationOptions, $listingProductVariationOptions)) {
continue;
}
foreach ($listingProductVariationOptions as $listingProductVariationOption) {
foreach ($magentoVariationOptions as $magentoVariationOption) {
if ($listingProductVariationOption['attribute'] != $magentoVariationOption['attribute'] || $listingProductVariationOption['option'] != $magentoVariationOption['option']) {
continue;
}
if ($listingProductVariationOption['product_id'] == $magentoVariationOption['product_id']) {
continue;
}
$listingProductVariationOption['product_id'] = $magentoVariationOption['product_id'];
Mage::helper('M2ePro/Component_Ebay')->getModel('Listing_Product_Variation_Option')->setData($listingProductVariationOption)->save();
}
}
}
}
}
示例3: updateVariations
public function updateVariations(Ess_M2ePro_Model_Listing_Product $listingProduct)
{
$options = array();
if ($listingProduct->getMagentoProduct()->isProductWithoutVariations()) {
$listingProduct->setData('is_variation_product', Ess_M2ePro_Model_Play_Listing_Product::IS_VARIATION_PRODUCT_NO)->save();
if ($listingProduct->getChildObject()->isVariationMatched()) {
$listingProduct->getChildObject()->updateVariationOptions($options);
$listingProduct->getChildObject()->unsetMatchedVariation();
}
return;
}
$listingProduct->setData('is_variation_product', Ess_M2ePro_Model_Play_Listing_Product::IS_VARIATION_PRODUCT_YES)->save();
$magentoVariations = $listingProduct->getMagentoProduct()->getProductVariations();
foreach ($magentoVariations['set'] as $attribute => $value) {
$options[] = array('attribute' => $attribute, 'option' => NULL);
}
if (!$listingProduct->getChildObject()->isVariationMatched()) {
$listingProduct->getChildObject()->updateVariationOptions($options);
return;
}
// observe variation removal in Magento
$currentVariation = $this->prepareCurrentVariations($listingProduct->getVariations(true));
if (!isset($currentVariation[0]) || !isset($currentVariation[0]['options'])) {
return;
}
$currentVariation = reset($currentVariation);
$magentoVariations = $this->prepareMagentoVariations($magentoVariations);
foreach ($magentoVariations as $magentoVariation) {
if ($this->isEqualVariations($magentoVariation['options'], $currentVariation['options'])) {
return;
}
}
foreach ($listingProduct->getVariations(true) as $variation) {
$variation->deleteInstance();
}
$listingProduct->getChildObject()->updateVariationOptions($options);
$listingProduct->getChildObject()->unsetMatchedVariation();
}
示例4: isAddedNewVariationsAttributes
public function isAddedNewVariationsAttributes(Ess_M2ePro_Model_Listing_Product $listingProduct)
{
if (!$listingProduct->getChildObject()->isVariationMode()) {
return false;
}
$rawMagentoVariations = $listingProduct->getMagentoProduct()->getProductVariations();
$rawMagentoVariations = $this->validateLimitsConditions($rawMagentoVariations, NULL);
$magentoVariations = $this->prepareMagentoVariations($rawMagentoVariations);
$currentVariations = $this->prepareCurrentVariations($listingProduct->getVariations(true));
if (!isset($magentoVariations[0]) && !isset($currentVariations[0])) {
return false;
}
if (!isset($magentoVariations[0]) || !isset($currentVariations[0])) {
return true;
}
if (count($magentoVariations[0]['options']) != count($currentVariations[0]['options'])) {
return true;
}
return false;
}
示例5: updateAfterStopAction
public function updateAfterStopAction(Ess_M2ePro_Model_Listing_Product $listingProduct, array $nativeRequestData = array(), array $params = array())
{
// Update Listing Product
//---------------------
$dataForUpdate = array('status' => Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED);
if (isset($params['status_changer'])) {
$dataForUpdate['status_changer'] = (int) $params['status_changer'];
}
if (isset($params['end_date_raw'])) {
$dataForUpdate['end_date'] = Ess_M2ePro_Model_Connector_Server_Ebay_Abstract::ebayTimeToString($params['end_date_raw']);
}
$listingProduct->addData($dataForUpdate)->save();
//---------------------
// Update Variations
//---------------------
$productVariations = $listingProduct->getVariations(true);
foreach ($productVariations as $variation) {
/** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
$dataForUpdate = array('add' => Ess_M2ePro_Model_Listing_Product_Variation::ADD_NO);
if ($variation->isListed()) {
$dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED;
}
$variation->addData($dataForUpdate)->save();
}
//---------------------
}
示例6: updateListingsProductChange
private function updateListingsProductChange(Ess_M2ePro_Model_Listing_Product $listingProduct)
{
Mage::getModel('M2ePro/ProductChange')->addUpdateAction($listingProduct->getProductId(), Ess_M2ePro_Model_ProductChange::CREATOR_TYPE_SYNCHRONIZATION);
$variations = $listingProduct->getVariations(true);
foreach ($variations as $variation) {
/** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
$options = $variation->getOptions(true);
foreach ($options as $option) {
/** @var $option Ess_M2ePro_Model_Listing_Product_Variation_Option */
Mage::getModel('M2ePro/ProductChange')->addUpdateAction($option->getProductId(), Ess_M2ePro_Model_ProductChange::CREATOR_TYPE_SYNCHRONIZATION);
}
}
}
示例7: createNewAmazonItem
protected function createNewAmazonItem(Ess_M2ePro_Model_Listing_Product $listingProduct, $sku)
{
$dataForAdd = array('account_id' => (int) $listingProduct->getListing()->getAccountId(), 'marketplace_id' => (int) $listingProduct->getListing()->getMarketplaceId(), 'sku' => $sku, 'product_id' => (int) $listingProduct->getProductId(), 'store_id' => (int) $listingProduct->getListing()->getStoreId());
if ($listingProduct->getChildObject()->isVariationMatched() && $listingProduct->getChildObject()->isVariationProduct()) {
$variations = $listingProduct->getVariations(true);
/* @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
$variation = reset($variations);
$options = $variation->getOptions();
$dataForAdd['variation_options'] = array();
foreach ($options as $optionData) {
$dataForAdd['variation_options'][$optionData['attribute']] = $optionData['option'];
}
$dataForAdd['variation_options'] = json_encode($dataForAdd['variation_options']);
}
return Mage::getModel('M2ePro/Amazon_Item')->setData($dataForAdd)->save()->getId();
}
示例8: prepareChangedListingsProducts
private function prepareChangedListingsProducts(Ess_M2ePro_Model_Listing_Product $tempListingProductModel, $ebayChange)
{
/** @var $tempEbayListingProductModel Ess_M2ePro_Model_Ebay_Listing_Product */
$tempEbayListingProductModel = $tempListingProductModel->getChildObject();
// Prepare eBay changes values
//--------------------------
$tempEbayChanges = array();
if ($tempEbayListingProductModel->isListingTypeAuction()) {
$tempEbayChanges['online_start_price'] = (double) $ebayChange['currentPrice'] < 0 ? 0 : (double) $ebayChange['currentPrice'];
}
if ($tempEbayListingProductModel->isListingTypeFixed()) {
$tempEbayChanges['online_buyitnow_price'] = (double) $ebayChange['currentPrice'] < 0 ? 0 : (double) $ebayChange['currentPrice'];
}
$tempEbayChanges['online_qty'] = (int) $ebayChange['quantity'] < 0 ? 0 : (int) $ebayChange['quantity'];
$tempEbayChanges['online_qty_sold'] = (int) $ebayChange['quantitySold'] < 0 ? 0 : (int) $ebayChange['quantitySold'];
if ($tempEbayListingProductModel->isListingTypeAuction()) {
$tempEbayChanges['online_qty'] = 1;
$tempEbayChanges['online_bids'] = (int) $ebayChange['bidCount'] < 0 ? 0 : (int) $ebayChange['bidCount'];
}
$tempEbayChanges['start_date'] = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($ebayChange['startTime']);
$tempEbayChanges['end_date'] = Ess_M2ePro_Model_Connector_Ebay_Abstract::ebayTimeToString($ebayChange['endTime']);
if ($tempEbayChanges['online_qty'] == $tempEbayChanges['online_qty_sold'] && ($ebayChange['listingStatus'] == self::EBAY_STATUS_COMPLETED || $ebayChange['listingStatus'] == self::EBAY_STATUS_ENDED)) {
$tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_SOLD;
} else {
if ($ebayChange['listingStatus'] == self::EBAY_STATUS_COMPLETED) {
$tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED;
} else {
if ($ebayChange['listingStatus'] == self::EBAY_STATUS_ENDED) {
$tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_FINISHED;
} else {
if ($ebayChange['listingStatus'] == self::EBAY_STATUS_ACTIVE) {
$tempEbayChanges['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_LISTED;
}
}
}
}
if ($tempListingProductModel->getStatus() != $tempEbayChanges['status'] || $tempListingProductModel->getChildObject()->getOnlineQty() != $tempEbayChanges['online_qty'] || $tempListingProductModel->getChildObject()->getOnlineQtySold() != $tempEbayChanges['online_qty_sold']) {
Mage::getModel('M2ePro/ProductChange')->addUpdateAction($tempListingProductModel->getProductId(), Ess_M2ePro_Model_ProductChange::CREATOR_TYPE_SYNCHRONIZATION);
}
if ($tempEbayChanges['status'] != $tempListingProductModel->getStatus()) {
$tempEbayChanges['status_changer'] = Ess_M2ePro_Model_Listing_Product::STATUS_CHANGER_COMPONENT;
$tempLogMessage = '';
switch ($tempEbayChanges['status']) {
case Ess_M2ePro_Model_Listing_Product::STATUS_LISTED:
// Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Listed".');
$tempLogMessage = 'Item status was successfully changed to "Listed".';
break;
case Ess_M2ePro_Model_Listing_Product::STATUS_SOLD:
// Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Sold".');
$tempLogMessage = 'Item status was successfully changed to "Sold".';
break;
case Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED:
// Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Stopped".');
$tempLogMessage = 'Item status was successfully changed to "Stopped".';
break;
case Ess_M2ePro_Model_Listing_Product::STATUS_FINISHED:
// Parser hack -> Mage::helper('M2ePro')->__('Item status was successfully changed to "Finished".');
$tempLogMessage = 'Item status was successfully changed to "Finished".';
break;
}
$tempLog = Mage::getModel('M2ePro/Listing_Log');
$tempLog->setComponentMode(Ess_M2ePro_Helper_Component_Ebay::NICK);
$tempLog->addProductMessage($tempListingProductModel->getListingId(), $tempListingProductModel->getProductId(), $tempListingProductModel->getId(), Ess_M2ePro_Model_Log_Abstract::INITIATOR_EXTENSION, $this->getLogActionId(), Ess_M2ePro_Model_Listing_Log::ACTION_CHANGE_STATUS_ON_CHANNEL, $tempLogMessage, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_LOW);
}
//--------------------------
// Create changed listings products
//--------------------------
$changedListingsProducts = array('ebay_item_id' => $ebayChange['id'], 'listing_product' => array('instance' => $tempListingProductModel, 'changes' => $tempEbayChanges), 'listings_products_variations' => array());
//--------------------------
// Cancel when have not eBay variations
//--------------------------
if (!isset($ebayChange['variations']) || is_null($ebayChange['variations'])) {
return $changedListingsProducts;
}
//--------------------------
// Get listings products variations
//-----------------------
$tempVariations = $tempListingProductModel->getVariations(true);
if (count($tempVariations) == 0) {
return $changedListingsProducts;
}
//-----------------------
// Get listings products variations with options
//-----------------------
$tempVariationsWithOptions = array();
foreach ($tempVariations as $variation) {
/** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
$options = $variation->getOptions(true);
if (count($options) == 0) {
continue;
}
$tempVariationsWithOptions[] = array('variation' => $variation, 'options' => $options);
}
if (count($tempVariationsWithOptions) == 0) {
return $changedListingsProducts;
}
//-----------------------
// Search our variations for eBay variations
//--------------------------
foreach ($ebayChange['variations'] as $ebayVariation) {
//.........这里部分代码省略.........
示例9: linkItem
private function linkItem(Ess_M2ePro_Model_Listing_Product $listingProduct)
{
$data = array('general_id' => $listingProduct->getData('general_id'), 'sku' => $listingProduct->getData('sku'), 'status' => Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED);
$listingProduct->addData($data)->save();
$dataForAdd = array('account_id' => $listingProduct->getListing()->getAccountId(), 'marketplace_id' => $listingProduct->getListing()->getMarketplaceId(), 'sku' => $listingProduct->getData('sku'), 'product_id' => $listingProduct->getProductId(), 'store_id' => $listingProduct->getListing()->getStoreId());
if ($listingProduct->getChildObject()->isVariationsReady()) {
$variations = $listingProduct->getVariations(true);
/* @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
$variation = reset($variations);
$options = $variation->getOptions();
$dataForAdd['variation_options'] = array();
foreach ($options as $optionData) {
$dataForAdd['variation_options'][$optionData['attribute']] = $optionData['option'];
}
$dataForAdd['variation_options'] = json_encode($dataForAdd['variation_options']);
}
Mage::getModel('M2ePro/Buy_Item')->setData($dataForAdd)->save();
$message = Mage::helper('M2ePro')->__('The product was found in your Rakuten.com inventory and linked by Reference ID.');
$this->addListingsProductsLogsMessage($listingProduct, $message, Ess_M2ePro_Model_Log_Abstract::TYPE_SUCCESS, Ess_M2ePro_Model_Log_Abstract::PRIORITY_MEDIUM);
}
示例10: updateAfterAction
public function updateAfterAction(Ess_M2ePro_Model_Listing_Product $listingProduct, array $nativeRequestData = array(), array $params = array(), $saveEbayQtySold = false)
{
if (!$listingProduct->getChildObject()->isListingTypeFixed() || !$listingProduct->getGeneralTemplate()->getChildObject()->isVariationMode() || $listingProduct->getMagentoProduct()->isProductWithoutVariations()) {
return;
}
// Delete Variations
//-----------------------------
$productVariations = $listingProduct->getVariations(true);
foreach ($productVariations as $variation) {
/** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
$variation->isDelete() && $variation->deleteInstance();
}
//-----------------------------
// Update Variations
//-----------------------------
$productVariations = $listingProduct->getVariations(true);
foreach ($productVariations as $variation) {
/** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
$dataForUpdate = array('online_price' => $variation->getChildObject()->getPrice(), 'add' => Ess_M2ePro_Model_Listing_Product_Variation::ADD_NO, 'delete' => Ess_M2ePro_Model_Listing_Product_Variation::DELETE_NO, 'status' => Ess_M2ePro_Model_Listing_Product::STATUS_LISTED);
if ($saveEbayQtySold) {
$dataForUpdate['online_qty_sold'] = is_null($variation->getChildObject()->getOnlineQtySold()) ? 0 : $variation->getChildObject()->getOnlineQtySold();
$dataForUpdate['online_qty'] = $variation->getChildObject()->getQty() + $dataForUpdate['online_qty_sold'];
} else {
$dataForUpdate['online_qty_sold'] = 0;
$dataForUpdate['online_qty'] = $variation->getChildObject()->getQty();
}
if ($dataForUpdate['online_qty'] <= $dataForUpdate['online_qty_sold']) {
$dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_SOLD;
}
if ($dataForUpdate['online_qty'] <= 0) {
$dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED;
}
$variation->addData($dataForUpdate)->save();
}
//-----------------------------
}
示例11: updateListingsProductChange
private function updateListingsProductChange(Ess_M2ePro_Model_Listing_Product $listingProduct)
{
Mage::getModel('M2ePro/ProductChange')->addUpdateAction($listingProduct->getProductId(), Ess_M2ePro_Model_ProductChange::INITIATOR_INSPECTOR);
foreach ($listingProduct->getVariations(true) as $variation) {
/** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
foreach ($variation->getOptions(true) as $option) {
/** @var $option Ess_M2ePro_Model_Listing_Product_Variation_Option */
Mage::getModel('M2ePro/ProductChange')->addUpdateAction($option->getProductId(), Ess_M2ePro_Model_ProductChange::INITIATOR_INSPECTOR);
}
}
}
示例12: updateAfterAction
public function updateAfterAction(Ess_M2ePro_Model_Listing_Product $listingProduct, array $nativeRequestData = array(), array $params = array(), $saveEbayQtySold = false)
{
if (!$listingProduct->getChildObject()->isListingTypeFixed() || !$listingProduct->getChildObject()->isVariationMode() || $listingProduct->getMagentoProduct()->isProductWithoutVariations()) {
return;
}
$isImagesUploadError = isset($params['is_images_upload_error']) ? $params['is_images_upload_error'] : false;
if (isset($nativeRequestData['variation_image']) && !$isImagesUploadError) {
$additionalData = $listingProduct->getAdditionalData();
$additionalData['ebay_product_variation_images_hash'] = sha1(json_encode($nativeRequestData['variation_image']));
$listingProduct->setData('additional_data', json_encode($additionalData))->save();
}
// Delete Variations
//-----------------------------
$productVariations = $listingProduct->getVariations(true);
foreach ($productVariations as $variation) {
/** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
$variation->getChildObject()->isDelete() && $variation->deleteInstance();
}
//-----------------------------
// Update Variations
//-----------------------------
$productVariations = $listingProduct->getVariations(true);
foreach ($productVariations as $variation) {
/** @var $variation Ess_M2ePro_Model_Listing_Product_Variation */
$dataForUpdate = array('online_price' => $variation->getChildObject()->getPrice(), 'add' => 0, 'delete' => 0, 'status' => Ess_M2ePro_Model_Listing_Product::STATUS_LISTED);
if ($saveEbayQtySold) {
$dataForUpdate['online_qty_sold'] = is_null($variation->getChildObject()->getOnlineQtySold()) ? 0 : $variation->getChildObject()->getOnlineQtySold();
$dataForUpdate['online_qty'] = $variation->getChildObject()->getQty() + $dataForUpdate['online_qty_sold'];
} else {
$dataForUpdate['online_qty_sold'] = 0;
$dataForUpdate['online_qty'] = $variation->getChildObject()->getQty();
}
if ($dataForUpdate['online_qty'] <= $dataForUpdate['online_qty_sold']) {
$dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_SOLD;
}
if ($dataForUpdate['online_qty'] <= 0) {
$dataForUpdate['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED;
}
$variation->addData($dataForUpdate)->save();
}
//-----------------------------
}