Ejemplo n.º 1
0
function aa_admin_items_page()
{
    global $wpdb, $item;
    $items = AA_Items::get();
    if (empty($items)) {
        echo 'Keine Produkte in Datenbank importiert';
    } else {
        ?>
        <table class="widefat">
            <thead>
		<tr>
		<th>Titel</th>
		<th>Hersteller</th>
		<th>Preis</th>
		</tr>
            </thead>
            <tbody>
                <?php 
        $rowno = 0;
        $event_count = 0;
        foreach ($items as $item) {
            $rowno++;
            $class = $rowno % 2 ? 'alternate' : '';
            ?>
                    <tr class="<?php 
            echo trim($class);
            ?>
" id="item_<?php 
            echo $item->item_id;
            ?>
">
                        <td>
                            <strong>
				<a class="row-title" href="<?php 
            bloginfo('wpurl');
            ?>
/wp-admin/admin.php?page=aa_edit_item&amp;action=item_edit&amp;item_id=<?php 
            echo $item->item_id;
            ?>
"><?php 
            echo $item->item_title;
            ?>
</a>
                            </strong>
                            <div class="row-actions">
				<span class="trash"><a href="<?php 
            bloginfo('wpurl');
            ?>
/wp-admin/admin.php?page=aa_edit_item&action=item_delete&amp;item_id=<?php 
            echo $item->item_id;
            ?>
">löschen</a></span>
                            </div>
                        </td>
                        <td>
                            <?php 
            echo $item->item_manufacturer;
            ?>
                        </td>
                        <td>
                            <?php 
            echo $item->item_price;
            ?>
                        </td>
                    </tr>
                    <?php 
        }
        ?>
            </tbody>
        </table>


<?php 
    }
}
Ejemplo n.º 2
0
/**
 * function executed every hour on cron job
 */
function updateItemsDataHourly()
{
    $appid = get_option('dbaa_amazon_appid');
    $coutryCode = get_option('dbaa_amazon_coutnrycode');
    $secretKey = get_option('dbaa_amazon_secretkey');
    $associatetag = get_option('dbaa_amazon_associatetag');
    if ($appid != '' && $coutryCode != '' && $secretKey != '') {
        $amazon = new Zend_clicks_Service_Amazon($appid, $coutryCode, $secretKey);
        $results = AA_Items::get();
        foreach ($results as $result) {
            $amazonresults = $amazon->itemLookup($result->item_asin, array('AssociateTag' => $associatetag, 'ResponseGroup' => 'Small, OfferFull, ItemAttributes'));
            foreach ($amazonresults as $amazonresult) {
                $vk = 'bla';
                if (isset($amazonresult->Offers->Offers)) {
                    $vk = $amazonresult->Offers->Offers[0]->FormattedPrice;
                } elseif (isset($amazonresult->FormattedPrice)) {
                    $vk = $amazonresult->FormattedPrice;
                }
                if ($result->item_price != $vk) {
                    AA_Item::updatePrice($vk, $result->item_id);
                }
            }
        }
    }
}